<a-spin :spinning="stateLi.spinning">
    <div class="my-page">
      <div class="content-box">
        <div class="right-table">
          <div class="search">
            <a-form :label-col="{ span: 10 }">
              <a-row>
                <a-col :span="5">
                  <a-form-item label="任务名称">
                    <a-select
                      v-model:value="stateLi.filterLi.taskName"
                      showSearch
                      allowClear
                      :options="stateLi.taskList"
                      @focus="getTaskList()"
                      :field-names="{ label: 'taskName', value: 'taskName' }"
                      :filter-option="
(input, option) => {
return option.taskName.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
"
                    />
                  </a-form-item>
                </a-col>
                <a-col :span="5">
                  <a-form-item label="任务执行人">
                    <a-select
                      v-model:value="stateLi.filterLi.taskParticipantStr"
                      mode="multiple"
                      allowClear
                      showSearch
                      :options="peopleList"
                      :field-names="{ label: 'label', value: 'value' }"
                      :filter-option="
(input, option) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
"
                    />
                  </a-form-item>
                </a-col>
                <a-col :span="5">
                  <a-form-item label="任务计划结束时间">
                    <a-date-picker v-model:value="stateLi.filterLi.endTime" valueFormat="YYYY-MM-DD" />
                  </a-form-item>
                </a-col>
                <a-col :span="5">
                  <a-form-item label="任务负责人">
                    <a-select
                      v-model:value="stateLi.filterLi.taskOwner"
                      allowClear
                      showSearch
                      :options="peopleList"
                      :field-names="{ label: 'label', value: 'value' }"
                      :filter-option="
(input, option) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
"
                    />
                  </a-form-item>
                </a-col>
                <a-col :span="4">
                  <a-form-item label="任务上下线">
                    <a-select
                      v-model:value="stateLi.filterLi.taskStatusOnOrOff"
                      allowClear
                      showSearch
                      :options="[
{ label: '全部', value: '全部' },
{ label: '上线', value: 'true' },
{ label: '下线', value: 'false' }
]"
                    />
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row>
                <a-col :span="5">
                  <a-form-item label="任务状态">
                    <a-select
                      v-model:value="stateLi.filterLi.taskStatusList"
                      mode="multiple"
                      allowClear
                      showSearch
                      :options="[
{ label: '未启动', value: '未启动' },
{ label: '进行中', value: '进行中' },
{ label: '完成', value: '完成' },
{ label: '延期', value: '延期' },
{ label: '延期完成', value: '延期完成' }
]"
                    />
                  </a-form-item>
                </a-col>
                <a-col :span="5">
                  <a-form-item label="工时投入状态">
                    <a-select
                      v-model:value="stateLi.filterLi.stateInput"
                      showSearch
                      allowClear
                      :options="[
{ label: '正常', value: '正常' },
{ label: '超出', value: '超出' }
]"
                    />
                  </a-form-item>
                </a-col>
                <a-col :span="5">
                  <a-form-item label="优先级">
                    <a-select
                      v-model:value="stateLi.filterLi.priorityStr"
                      showSearch
                      allowClear
                      :options="[
{ label: '最高', value: '最高' },
{ label: '高', value: '高' },
{ label: '中', value: '中' },
{ label: '低', value: '低' },
{ label: '最低', value: '最低' }
]"
                    />
                  </a-form-item>
                </a-col>
                <a-col :span="5">
                  <a-form-item label="所属项目阶段">
                    <a-select
                      v-model:value="stateLi.filterLi.milepostId"
                      showSearch
                      allowClear
                      :options="stateLi.milepostList"
                      :field-names="{ label: 'milepostName', value: 'milepostId' }"
                      :filter-option="
(input, option) => {
return option.milepostName.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
"
                    />
                  </a-form-item>
                </a-col>
                <a-col :span="4">
                  <a-form-item>
                    <a-button type="primary" class="mr16 ml10" @click="getTableData"> 查询 </a-button>
                    <a-button class="mr16" @click="resetSearch">重置</a-button>
                  </a-form-item>
                </a-col>
              </a-row>
            </a-form>
          </div>
          <div class="table-box">
            <div class="table-form-box">
              <span> 任务</span>
              <a-space>
                <!-- <a-button type="primary" ghost  @click="handlerAdd"> 新建 </a-button> -->
                <a-button type="primary" ghost :disabled="!projectId || !isTask" @click="handlerAdd"> 新建 </a-button>

                <a-upload :before-upload="handlerTaskImport" :file-list="[]" :disabled="!projectId || !stateLi.projectManager || !isTask" accept=".xlsx, image/*, .docx, .rp, .xls">
                  <a-button :disabled="!projectId || !stateLi.projectManager || !isTask || isTemplate">导入</a-button>
                </a-upload>
                <a-button :disabled="!projectId || !stateLi.projectManager || !isTask" @click="handlerTaskExport">导出</a-button>
              </a-space>
            </div>
            <a-table
              bordered
              rowKey="taskId"
              :loading="stateLi.tableLoading"
              :customRow="customRow"
              :columns="stateLi.columns"
              :data-source="stateLi.dataList"
              :pagination="false"
              :row-class-name="(_record, index) => (index % 2 === 1 ? 'table-striped' : null)"
              :scroll="{ x: scrollX, y: stateLi.dataList.length ? '500px' : '' }"
              @resizeColumn="handleTaskResizeColumn"
            >
              <template #bodyCell="{ column, record, text }">
                <template v-if="column.dataIndex === 'taskStatusOnOrOff'">
                  <a-switch :checked="record['taskStatusOnOrOff']" :disabled="record.nodeType === 'MENU' || !stateLi.projectManager" @click="changeTaskStatusOnOrOff(record)" />
                </template>
                <template v-if="column.dataIndex === 'taskStatus'">
                  <a-button v-if="text==='延期'" type="text" size="small" danger>{{ text }}</a-button>
                  <span v-else>{{text}}</span>
                </template>
                <template v-if="column.dataIndex === 'unclosedRiskNumber' || column.dataIndex === 'riskNumber'">
                  <a @click="handlerShowRisks(record, column.dataIndex === 'unclosedRiskNumber' ? '未关闭' : '全部')">
                    {{ text }}
                  </a>
                </template>
                <template v-if="column.dataIndex === 'attachment'">
                  <template v-if="record.previewPermission">
                    <a
                      v-for="(item, index) in record.ppmEnclosureInfoList"
                      :key="index"
                      href="javascript:"
                      @click="handlerDownload(item)"
                      :class="['block', index > 2 && !record.attachmentShowAll ? 'hide' : '']"
                    >
                      {{ item.name }}
                    </a>
                    <a v-if="record.ppmEnclosureInfoList.length > 3 && !record.attachmentShowAll" @click="record.attachmentShowAll = true">更多</a>
                  </template>
                  <template v-else>
                    <span v-for="(item, index) in record.ppmEnclosureInfoList" :key="index" :class="['block', index > 2 && !record.attachmentShowAll ? 'hide' : '']">
                      {{ item.name }}
                    </span>
                    <a v-if="record.ppmEnclosureInfoList.length > 3 && !record.attachmentShowAll" @click="record.attachmentShowAll = true">更多</a>
                  </template>
                </template>
                <template v-if="column.dataIndex === 'operation'">
                  <a-space v-if="record.nodeType === 'MENU'">
                    <a-button type="link" :disabled="record.disabledMenuEditBtn" @click="handlerEdit(record)"> 编辑 </a-button>
                    <a-popconfirm title="确定要删除吗？" :disabled="record.disabledMenuDelBtn" @confirm="handlerDelete(record)">
                      <a-button :disabled="record.disabledMenuDelBtn" type="link">删除</a-button>
                    </a-popconfirm>
                  </a-space>
                  <a-space v-else>
                    <a-button
                      v-if="(record.taskStatus === '完成' || record.taskStatus === '延期完成') && !record.instanceId"
                      type="link"
                      @click="handlerEdit(record, true)"
                      :disabled=" !record.uploadPermission "
                    >
                      恢复
                    </a-button>
                    <a-button v-else type="link" @click="beforeOk(record)"> 完成 </a-button>
                    <a-button type="link" :disabled="record.disabledEditBtn" @click="handlerEdit(record)"> 编辑 </a-button>
                    <!-- <a-button type="link"  @click="handlerEdit(record)"> 编辑 </a-button> -->
                    <a-popconfirm title="确定要删除吗？" :disabled="record.disabledDelBtn" @confirm="handlerDelete(record)">
                      <a-button :disabled="record.disabledDelBtn" type="link">删除</a-button>
                    </a-popconfirm>
                    <a-button type="link" :disabled="record.disabledRiskBtn" @click="handlerShowRisks(record)"> 风险 </a-button>
                    <a-button type="link" :disabled="record.disabledFileBtn" @click="handlerShowUpdate(record)"> 附件 </a-button>
                    <a-button type="link" :disabled="record.disabledNoteBtn" @click="handlerShowNotes(record)"> 备注 </a-button>
                  </a-space>
                </template>
              </template>
            </a-table>
          </div>
        </div>
      </div>

      <a-modal
        :visible="stateLi.visible"
        :title="`${current.taskId ? (current.restore ? '恢复' : '修改') : '新增'}任务`"
        destroyOnClose
        centered
        width="50%"
        :ok-button-props="{ disabled: btnLoading }"
        :getContainer="getModalContainer"
        @cancel="handlerCancel"
        @ok="beforeSubmit"
      >
        <a-form ref="formRef" :model="stateLi.ppmTaskFromList">
          <div v-for="(item, index) in stateLi.ppmTaskFromList" :key="index" class="form-item">
            <div class="form-content">
              <a-row class="one-line">
                <a-col :span="24">
                  <a-form-item label="任务类型" :name="[index, 'nodeType']" :rules="{ required: true, message: '请选择任务类型!' }">
                    <a-select
                      v-model:value="stateLi.ppmTaskFromList[index].nodeType"
                      :disabled="current.taskId"
                      showSearch
                      :options="[
{
label: '父级任务',
value: 'MENU'
},
{
label: '子任务',
value: 'TASK'
}
]"
                    />
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row>
                <a-col :span="12">
                  <a-form-item label="任务名称" :name="[index, 'taskName']" :rules="{ required: true, message: '请输入任务名称!' }">
                    <a-input placeholder="请输入任务名称" v-model:value="stateLi.ppmTaskFromList[index].taskName" :disabled="isTemplate" />
                  </a-form-item>
                </a-col>
                <a-col :span="12">
                  <a-form-item label="任务优先级" :name="[index, 'priority']" :rules="{ required: true, message: '请选择任务优先级!' }">
                    <a-select
                      placeholder="请选择任务优先级"
                      v-model:value="stateLi.ppmTaskFromList[index].priority"
                      showSearch
                      :options="[
{ label: '最高', value: 'HIGHEST' },
{ label: '高', value: 'HIGH' },
{ label: '中', value: 'MEDIUM' },
{ label: '低', value: 'LOW' },
{ label: '最低', value: 'LOWEST' }
]"
                    />
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row>
                <a-col :span="12">
                  <a-form-item label="项目阶段" :name="[index, 'milepostId']" :rules="{ required: true, message: '请选择项目阶段!' }">
                    <a-select
                      placeholder="请选择项目阶段"
                      v-model:value="stateLi.ppmTaskFromList[index].milepostId"
                      showSearch
                      :options="stateLi.milepostList"
                      :field-names="{ label: 'milepostName', value: 'milepostId' }"
                      @focus="getMilepostList"
                      @change="handlerMilepostIdChange(index)"
                      :filter-option="
(input, option) => {
return option.milepostName.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
"
                    />
                  </a-form-item>
                </a-col>
                <a-col :span="12">
                  <a-form-item label="父级任务">
                    <a-tree-select
                      placeholder="请选择父级任务"
                      v-model:value="stateLi.ppmTaskFromList[index].parentId"
                      allowClear
                      showSearch
                      :tree-data="stateLi.parentListMap[index]"
                      :field-names="{ label: 'taskName', value: 'taskId' }"
                      :filter-option="
(input, option) => {
return option.taskName.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
"
                    />
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row class="one-line">
                <a-col :span="24">
                  <a-form-item label="任务序号" :name="[index, 'taskIndex']" :rules="{ required: true, message: '请输入任务序号!' }">
                    <a-input placeholder="请输入任务序号" v-model:value="stateLi.ppmTaskFromList[index].taskIndex" :min="0" type="number" />
                  </a-form-item>
                </a-col>
              </a-row>
              <template v-if="stateLi.ppmTaskFromList[index].nodeType === 'TASK'">
                <a-row class="one-line"> </a-row>
                <a-row>
                  <a-col :span="12">
                    <a-form-item label="依赖任务">
                      <a-select
                        placeholder="请选择依赖任务"
                        v-model:value="stateLi.ppmTaskFromList[index].taskDependency"
                        allowClear
                        showSearch
                        :options="stateLi.taskList"
                        @focus="getTaskList()"
                        :field-names="{ label: 'taskName', value: 'taskId' }"
                        :filter-option="
(input, option) => {
return option.taskName.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
"
                      />
                    </a-form-item>
                  </a-col>
                  <a-col :span="12">
                    <a-form-item label="任务类型" :name="[index, 'taskType']" :rules="{ required: true, message: '请选择任任务类型!' }">
                      <a-select
                        placeholder="请选择任务类型"
                        v-model:value="stateLi.ppmTaskFromList[index].taskType"
                        showSearch
                        :options="[
{ label: '主任务', value: '主任务' },
{ label: '辅助任务', value: '辅助任务' },
{ label: '其他任务', value: '其他任务' }
]"
                      />
                    </a-form-item>
                  </a-col>
                </a-row>

                <a-row>
                  <a-col :span="12">
                    <a-form-item
                      label="预计投入工时"
                      :name="[index, 'workingHours']"
                      :rules="[
{ required: true, message: '请输入预计投入工时!', trigger: 'blur' },
{ pattern: /^(0\.5|[1-9](\d*)?(\.5)?(\.0)?)$/, message: '请输入大于0的数字(支持0.5的倍数)', trigger: 'blur' }
]"
                    >
                      <a-input placeholder="请输入工时(支持0.5的数字)" v-model:value="stateLi.ppmTaskFromList[index].workingHours" type="number" suffix="小时" />
                    </a-form-item>
                  </a-col>
                  <a-col :span="12">
                    <a-form-item label="任务起止时间" :name="[index, 'allTime']" :rules="{ required: true, message: '请选择任务起止时间!' }">
                      <a-range-picker v-model:value="stateLi.ppmTaskFromList[index].allTime" valueFormat="YYYY-MM-DD" />
                    </a-form-item>
                  </a-col>
                </a-row>
                <a-row>
                  <a-col :span="12">
                    <a-form-item label="任务负责人" :name="[index, 'taskOwner']" :rules="{ required: true, message: '请选择任务负责人!' }">
                      <a-select
                        placeholder="请选择任务负责人"
                        v-model:value="stateLi.ppmTaskFromList[index].taskOwner"
                        showSearch
                        :options="peopleList"
                        :field-names="{ label: 'label', value: 'value' }"
                        :filter-option="
(input, option) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
"
                      />
                    </a-form-item>
                  </a-col>
                  <a-col :span="12">
                    <a-form-item label="是否必须提交输出物" :name="[index, 'output']" :rules="{ required: true, message: '请选择是否必须提交输出物!' }">
                      <a-select
                        placeholder="请选择是否必须提交输出物"
                        v-model:value="stateLi.ppmTaskFromList[index].output"
                        showSearch
                        :options="[
{ label: '是', value: '是' },
{ label: '否', value: '否' }
]"
                      />
                    </a-form-item>
                  </a-col>
                </a-row>
                <a-row>
                  <a-col :span="12">
                    <a-form-item label="审核员" :name="[index, 'assessorName']" :rules="{ required: true, message: '请选择审核员!' }">
                      <a-select
                        placeholder="请选择审核员"
                        v-model:value="stateLi.ppmTaskFromList[index].assessorName"
                        showSearch
                        :options="peopleList"
                        :field-names="{ label: 'label', value: 'value' }"
                        :filter-option="
(input, option) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
"
                      />
                    </a-form-item>
                  </a-col>
                </a-row>
                <a-row class="one-line">
                  <a-col :span="24">
                    <a-form-item label="任务执行人" :name="[index, 'taskParticipantList']" :rules="{ required: true, message: '请选择任务参与人!' }">
                      <a-select
                        placeholder="请选择任务参与人"
                        v-model:value="stateLi.ppmTaskFromList[index].taskParticipantList"
                        showSearch
                        mode="multiple"
                        :options="peopleList"
                        :field-names="{ label: 'label', value: 'value' }"
                        :filter-option="
(input, option) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
"
                      />
                    </a-form-item>
                  </a-col>
                  <a-col v-if="taskPeopleList.length>0">
                    <div style="width:700px;margin-left:115px;margin-bottom:28px">
                      <a href="javascript:;" v-for="(item,num) in taskPeopleList" @click="handlerAddPeople(item.value,index)"
                        ><span style="margin:0 5px">{{item.value}}</span></a
                      >
                    </div>
                  </a-col>
                </a-row>
                <a-row class="one-line">
                  <a-col :span="24">
                    <a-form-item label="验收标准">
                      <a-textarea v-model:value="stateLi.ppmTaskFromList[index].acceptanceCriteria" placeholder="请输入验收标准" />
                    </a-form-item>
                  </a-col>
                </a-row>
                <a-row class="one-line">
                  <a-col :span="24">
                    <a-form-item label="甲方工作事项" :rules="{ required: true, message: '请选择任务参与人!' }" name="taskRemarks">
                      <a-textarea v-model:value="stateLi.ppmTaskFromList[index].taskRemarks" placeholder="请输入甲方工作事项" />
                    </a-form-item>
                  </a-col>
                </a-row>
                <a-row class="one-line">
                  <a-col :span="24">
                    <a-form-item label="备注">
                      <a-textarea placeholder="请输入备注" v-model:value="stateLi.ppmTaskFromList[index].description" />
                    </a-form-item>
                  </a-col>
                </a-row>
                <a-row class="one-line" v-if="current.taskId">
                  <a-col :span="24">
                    <a-form-item label="变更原因" :name="[index, 'reasonsChange']" :rules="{ required: true, message: '请填写变更原因!' }">
                      <a-textarea placeholder="请输入变更原因" v-model:value="stateLi.ppmTaskFromList[index].reasonsChange" />
                    </a-form-item>
                  </a-col>
                </a-row>
              </template>
            </div>
            <a v-if="!current.taskId" class="del" @click="handlerDeleteFormItem(index)">删除</a>
          </div>
        </a-form>
        <a-button v-if="!current.taskId" type="primary" ghost class="add-btn" @click="handlerAddFormItem">
          <plus-outlined />
          添加
        </a-button>
      </a-modal>

      <a-modal
        :visible="stateLi.closeVisible"
        title="关闭风险"
        destroyOnClose
        centered
        width="40%"
        :ok-button-props="{ disabled: btnLoading }"
        @cancel="stateLi.closeVisible = false"
        @ok="handlerClose"
      >
        <a-form ref="closeFormRef" :model="closeCurrent">
          <div class="form-content">
            <a-row>
              <a-col :span="24">
                <a-form-item label="风险关闭备注" name="riskRemarks" :rules="{ required: true, message: '请输入风险关闭备注!' }">
                  <a-textarea v-model:value="closeCurrent.riskRemarks" :rows="5" />
                </a-form-item>
              </a-col>
            </a-row>
          </div>
        </a-form>
      </a-modal>

      <a-modal
        :visible="stateLi.visibleNotes"
        title="备注"
        width="40vw"
        centered
        destroyOnClose
        :footer="null"
        :getContainer="getModalContainer"
        @cancel="stateLi.visibleNotes = false"
      >
        <a-table
          bordered
          rowKey="taskId"
          :customRow="customRow"
          :columns="stateLi.notesColumns"
          :data-source="stateLi.noteData.descriptionDataList"
          :pagination="false"
          :row-class-name="(_record, index) => (index % 2 === 1 ? 'table-striped' : null)"
        />
      </a-modal>

      <a-modal :visible="stateLi.visibleRisk" title="风险" width="80vw" centered destroyOnClose :footer="null" :getContainer="getModalContainer" @cancel="stateLi.visibleRisk = false">
        <a-table
          bordered
          rowKey="taskId"
          :customRow="customRow"
          :columns="stateLi.riskColumns"
          :data-source="stateLi.riskList"
          :pagination="false"
          :row-class-name="(_record, index) => (index % 2 === 1 ? 'table-striped' : null)"
        >
          <template #bodyCell="{ column, record }">
            <template v-if="column.dataIndex === 'operation'">
              <a-button type="link" :disabled="record.riskState === '关闭'" @click="handlerBeforeClose(record)">关闭</a-button>
            </template>
          </template>
        </a-table>
      </a-modal>

      <a-modal
        :visible="stateLi.visibleFile"
        title="上传附件"
        destroyOnClose
        centered
        :ok-button-props="{ disabled: btnLoading }"
        :getContainer="getModalContainer"
        @cancel="stateLi.visibleFile = false"
        @ok="handlerUpdateFile"
      >
        <a-upload :file-list="stateLi.fileList" :before-upload="handlerUpload" @remove="handleRemove" accept=".xlsx,.ppt,.pdf,.PDF, image/*, .docx, .rp, .xls">
          <a-button type="primary">
            <upload-outlined />
            上传
          </a-button>
        </a-upload>
        <span>支持格式：image/*,.xlsx,.xls,.docx,.rp,.ppt,.pptx,.pdf</span>
      </a-modal>
      <!--  :ok-button-props="{ disabled: ppmCheckedListLen !== ppmCheckedList.length }" -->
      <a-modal
        :visible="stateLi.okVisible"
        title="检查清单列表"
        destroyOnClose
        centered
        width="40%"
        :getContainer="getModalContainer"
        @cancel="stateLi.okVisible = false"
        @ok="handlerOk"
      >
        <div v-for="(item, index) in ppmCheckList" :key="index" class="checkbox-group">
          <div class="label">{{ item.name }}</div>
          <a-checkbox v-for="(item2, index2) in item.value" :key="index2" :checked="ppmCheckedList.includes(item2.checkEntryId)" @change="ppmCheckedListChange(item2.checkEntryId)">
            {{ item2.checkEntry }}
          </a-checkbox>
        </div>
      </a-modal>
    </div>
  </a-spin>


import { Textarea } from 'ant-design-vue'




    const userInfoStorage= localStorage.getItem('al__USER_INFO');
    if(userInfoStorage){
      try {
        const userInfo = JSON.parse(userInfoStorage);
        vid_uxyv015kln_props.value = userInfo.value.name;
      } catch(error) {
        console.log(error)
      }
    }


    import * as echarts from 'echarts'
          const state = reactive({
            apiData: {},
            value1: 'time',
            value2: 'time',
            value3: 'time'
          })

          const chart1 = ref(null)
          const chart2 = ref(null)
          const chart3 = ref(null)
          const chart4 = ref(null)
          const chart5 = ref(null)
          const chart6 = ref(null)
          const chart7 = ref(null)
          const chart8 = ref(null)

        function genChart1(data) {
          const { completeTask, started, delay, notStarted, totalTasks } = data

          const option = {

            tooltip: {
              trigger: 'axis',
              axisPointer: {
                // Use axis to trigger tooltip
                type: 'shadow' // 'shadow' as default; can also be 'line' or 'shadow'
              }
            },
            legend: {
              top: '5%'
            },
            color: ['#1AD52D', '#73B3FF', '#FF0000', '#F2BD42'],
            grid: {
              left: '3%',
              right: '4%',
              bottom: '3%',
              containLabel: true
            },
            xAxis: {
              type: 'value',
              max: totalTasks,
              axisLabel: {
                show: true
                // formatter: (value, index: number) => {
                //   return totalTasks ? `${index * 20} %` : ''
                // }
              }
            },
            yAxis: {
              type: 'category',
              data: ['项目进度']
            },
            series: [
              {
                name: '已完成任务',
                type: 'bar',
                stack: 'total',
                barWidth: 40,
                label: {
                  show: true
                },
                emphasis: {
                  focus: 'series'
                },
                data: [completeTask]
              },
              {
                name: '正常开发任务',
                type: 'bar',
                stack: 'total',
                label: {
                  show: true
                },
                emphasis: {
                  focus: 'series'
                },
                data: [started]
              },
              {
                name: '延期任务',
                type: 'bar',
                stack: 'total',
                label: {
                  show: true
                },
                emphasis: {
                  focus: 'series'
                },
                data: [delay]
              },
              {
                name: '待开发任务',
                type: 'bar',
                stack: 'total',
                label: {
                  show: true
                },
                emphasis: {
                  focus: 'series'
                },
                data: [notStarted]
              }
            ]
          }
          // debugger
          echarts.dispose(chart1.value)
           echarts.init(chart1.value).setOption(option)


        }
        function genChart2(data) {
          const { projectBudget, work, rate } = data
          const center = ['44%', '80%']
          const option = {
            series: [
              {
                type: 'gauge',
                radius: '120%',
                center,
                startAngle: 180,
                endAngle: -0,
                min: 0,
                max: projectBudget,
                splitNumber: 12,
                itemStyle: {
                  color: '#EBF1FF'
                },
                progress: {
                  show: true,
                  width: 30
                },
                pointer: {
                  show: false
                },
                axisLine: {
                  lineStyle: {
                    width: 30
                  }
                },
                axisTick: {
                  distance: -45,
                  splitNumber: 5,
                  lineStyle: {
                    width: 1,
                    color: '#999'
                  }
                },
                splitLine: {
                  distance: -52,
                  length: 14,
                  lineStyle: {
                    width: 1,
                    color: '#999'
                  }
                },
                axisLabel: {
                  show: false
                },
                anchor: {
                  show: false
                },
                title: {
                  show: false
                },
                detail: {
                  valueAnimation: true,
                  width: '60%',
                  lineHeight: 40,
                  borderRadius: 8,
                  offsetCenter: [0, '-15%'],
                  fontSize: 20,
                  fontWeight: 'bolder',
                  formatter: function () {
                    return '占比: {unit|' + rate.toFixed(0) + '%}'
                  },
                  rich: {
                    unit: {
                      fontSize: 26,
                      color: '#9AB8FF'
                    }
                  }
                },
                data: [
                  {
                    value: work
                  }
                ]
              },
              {
                type: 'gauge',
                radius: '120%',
                center,
                startAngle: 180,
                endAngle: -0,
                min: 0,
                max: projectBudget,
                itemStyle: {
                  color: '#3875FF'
                },
                progress: {
                  show: true,
                  width: 8
                },
                pointer: {
                  show: false
                },
                axisLine: {
                  show: false
                },
                axisTick: {
                  show: false
                },
                splitLine: {
                  show: false
                },
                axisLabel: {
                  show: false
                },
                detail: {
                  show: false
                },
                data: [
                  {
                    value: work
                  }
                ]
              }
            ]
          }
          echarts.dispose(chart2.value)
          echarts.init(chart2.value).setOption(option)
        }
        function genChart3(data) {
          const option = {
            tooltip: {
              trigger: 'item'
            },
            legend: {
              type: 'scroll',
              orient: 'vertical',
              right: 10,
              top: 'center',
              bottom: 20
            },
            color: ['#D95040', '#5087EC', '#68BBC4', '#58A55C', '#F2BD42', '#EE752F'],
            series: [
              {
                name: '',
                type: 'pie',
                center: ['40%', '50%'],
                radius: ['40%', '70%'],
                avoidLabelOverlap: false,
                itemStyle: {
                  borderRadius: 10,
                  borderColor: '#fff',
                  borderWidth: 2
                },
                label: {
                  show: false,
                  position: 'center'
                },
                emphasis: {
                  label: {
                    show: false
                  }
                },
                labelLine: {
                  show: false
                },
                data: (data ?? []).map(item => {
                  return { value: item.count, name: item.role }
                })
              }
            ]
          }
          echarts.dispose(chart3.value)
          echarts.init(chart3.value).setOption(option)
        }
        function genChart4(data) {
          const option = {
            color: ['#D95040', '#5087EC', '#68BBC4', '#58A55C', '#F2BD42', '#EE752F'],
            tooltip: {
              trigger: 'item'
            },
            legend: {
              show: false
            },
            series: [
              {
                name: '',
                type: 'pie',
                radius: ['40%', '70%'],
                avoidLabelOverlap: false,
                itemStyle: {
                  borderRadius: 10,
                  borderColor: '#fff',
                  borderWidth: 2
                },
                emphasis: {
                  label: {
                    show: false
                  }
                },
                data: (data ?? []).map(item => {
                  return { value: item.roleCost, name: item.role }
                })
              }
            ]
          }
          echarts.dispose(chart4.value)
          echarts.init(chart4.value).setOption(option)
        }
        function genChart5(data) {
          const option = {
            color: ['#5087EC', '#68BBC4', '#58A55C'],
            tooltip: {
              trigger: 'axis',
              axisPointer: {
                type: 'shadow'
              }
            },
            grid: {
              left: '3%',
              right: '4%',
              bottom: '3%',
              containLabel: true
            },
            xAxis: [
              {
                type: 'category',
                data: (data ?? []).map(item => item.role),
                axisTick: {
                  alignWithLabel: true
                }
              }
            ],
            yAxis: [
              {
                type: 'value',
                axisLabel: {
                  formatter: '{value} 人天'
                }
              }
            ],
            series: [
              {
                type: 'bar',
                barWidth: '30',
                data: (data ?? []).map(item => item.workingHours)
              }
            ]
          }
          echarts.dispose(chart5.value)
          echarts.init(chart5.value).setOption(option)
        }
        function genChart6() {
          const data = state.apiData.milestoneBudgetDtoList || {}
          const option = {
            color: ['#5087EC', '#68BBC4', '#58A55C'],
            tooltip: {
              trigger: 'axis',
              axisPointer: {
                type: 'shadow'
              }
            },
            legend: {},
            grid: {
              left: '3%',
              right: '4%',
              bottom: '3%',
              containLabel: true
            },
            yAxis: {
              type: 'value',
              boundaryGap: [0, 0.01],
              axisLabel: {
                formatter: `{value} ${state.value1 === 'time' ? '小时' : '元'}`
              }
            },
            xAxis: {
              type: 'category',
              data: (data ?? []).map(item => item.milepostName)
            },
            series: [
              {
                name: '预计',
                barWidth: 50,
                type: 'bar',
                data: (data ?? []).map(item => (state.value1 === 'time' ? item.estimateHours : item.milepostBudget))
              },
              {
                name: '实际',
                barWidth: 50,
                type: 'bar',
                data: (data ?? []).map(item => (state.value1 === 'time' ? item.workingHours : item.actualResources))
              }
            ]
          }
          echarts.dispose(chart6.value)
          echarts.init(chart6.value).setOption(option)
        }
        function genChart7() {
          const data = state.apiData.projectInputDtoList
          const option = {
            color: ['#5087EC', '#68BBC4', '#58A55C'],
            grid: {
              left: '3%',
              right: '4%',
              bottom: '3%',
              containLabel: true
            },
            tooltip: {
              trigger: 'axis'
            },
            xAxis: {
              type: 'category',
              data: (data ?? []).map(item => item.month)
            },
            yAxis: {
              type: 'value',
              axisLabel: {
                formatter: `{value} ${state.value2 === 'time' ? '小时' : '元'}`
              }
            },
            series: [
              {
                data: (data ?? []).map(item => (state.value2 === 'time' ? item.workingHour : item.resources)),
                type: 'line'
              }
            ]
          }
          echarts.dispose(chart7.value)
          echarts.init(chart7.value).setOption(option)
        }
        function genChart8() {
          const data = state.apiData.personResourceDtoList
          const option = {
            color: ['#5087EC', '#68BBC4', '#58A55C'],
            tooltip: {
              trigger: 'axis',
              axisPointer: {
                // Use axis to trigger tooltip
                type: 'shadow' // 'shadow' as default; can also be 'line' or 'shadow'
              }
            },
            legend: {},
            grid: {
              left: '3%',
              right: '4%',
              bottom: '3%',
              containLabel: true
            },
            yAxis: {
              type: 'value',
              axisLabel: {
                formatter: `{value} ${state.value3 === 'time' ? '小时' : '元'}`
              }
            },
            xAxis: {
              type: 'category',
              data: (data ?? []).map(item => item.name)
            },
            series: [
              {
                name: '成本',
                type: 'bar',
                barWidth: '50',
                stack: 'total',
                label: {
                  show: false
                },
                emphasis: {
                  focus: 'series'
                },
                data: (data ?? []).map(item => (state.value3 === 'time' ? item.workHours : item.resources))
              },
              {
                name: '报销',
                type: 'bar',
                stack: 'total',
                label: {
                  show: false
                },
                emphasis: {
                  focus: 'series'
                },
                data: []
              },
              {
                name: '其他',
                type: 'bar',
                stack: 'total',
                label: {
                  show: false
                },
                emphasis: {
                  focus: 'series'
                },
                data: []
              }
            ]
          }
          echarts.dispose(chart8.value)
          echarts.init(chart8.value).setOption(option)
        }

        function getProjectAnalysisEchart() {
            if (vid_rzym3dfyuw_props?.selected?.singleValue) {
              get(
                `/solution-ppm/api/v2/built-in-system-ppm/project/${vid_rzym3dfyuw_props?.selected?.singleValue}/analysis`
              ).then(data => {
                state.apiData = data
                const { projectOverallProgressDto, projectBudgetDto, roleStatisticsDtoList } = data
                genChart1(projectOverallProgressDto)
                genChart2(projectBudgetDto)
                genChart3(roleStatisticsDtoList)
                genChart4(roleStatisticsDtoList)
                genChart5(roleStatisticsDtoList)
                genChart6()
                genChart7()
                genChart8()
              })
            }
          }
          // watch(
          //   () => chart1.value,
          //   () => {
          //     if (chart1.value) {
          //       getProjectAnalysisEchart()
          //     }
          //   }
          // )


    //里程碑进度


    //里程碑进度
    const milestoneDataList = ref([])
    const overlayStyle = {
    width: '326px',
    borderRadius: '4px 4px 4px 0px 2px',
    maxWidth: 'unset',
    }
    function getMilepostData () {
    const params = {
      endTime: '',
      projectId:vid_rzym3dfyuw_props?.selected?.singleValue
    }
    post('/solution-ppm/api/v2/built-in-system-ppm/delivery_milepost/list', params).then(data => {
      milestoneDataList.value = data.data.dataList
      getMilepostChart()
    })
    }
    function getMilepostChart() {
      setTimeout(() => {
        renderCharts()
      }, 0)

    }

    function renderCharts() {
      for (let i = 0; i < milestoneDataList.value.length; i++) {
        const chartElement = document.getElementById(`chart${i}`);
        let chart = echarts.init(chartElement);

        const redTasks = milestoneDataList.value[i].percentageOfRedTasks;
        const greenTasks = milestoneDataList.value[i].percentageOfGreenTasks;
        const greyTasks = milestoneDataList.value[i].percentageOfGreyTasks;

        let data;

        if (redTasks === null && greenTasks === null && greyTasks === null) {
          data = [{ value: 1, itemStyle: { color: '#788397', opacity: 0.4 } }];
        } else {
          data = [
            { name: '超期', value: redTasks || 0, itemStyle: { color: '#FF2A00', opacity: 1 } },
            { name: '完成', value: greenTasks || 0, itemStyle: { color: '#38A45A', opacity: 0.8 } },
            { name: '未开始', value: greyTasks || 0, itemStyle: { color: '#788397', opacity: 0.4 } }
          ];
        }

        let option = {
          series: [{
            type: 'pie',
            radius: ['60%', '80%'],
            grid: {
              top: '5px',
              bottom: '5px',
              left: '5px',
              right: '5px'
            },
            labelLine: {
              show: false
            },
            data: data
          }]
        };

        chart.setOption(option);
      }
    }






    // 新增里程碑开始时间校验
    v_30blfqiwu1_rules.startTime=[
      {
        required: true,
    trigger: 'blur',
    validator: (rule, value, callback) =>{
      if(!value){
        return Promise.reject('请输入开始时间')
      }
      let index1 = rule.field.split('.')
        let index = Number(index1[1])
      // 与完成时间对比
      if ((value && v_30blfqiwu1.r_7p98nd8hab[index].endTime) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') > dayjs(v_30blfqiwu1.r_7p98nd8hab[index].endTime).format('YYYY-MM-DD hh-mm-ss')) {
        return Promise.reject('计划开始时间不能晚于计划完成时间')
      }
      return Promise.resolve()
    }
      }
    ]


    // // 新增里程碑完成时间

    v_30blfqiwu1_rules.endTime=[
      {
        required: true,
    trigger: 'blur',
    validator: (rule, value, callback) =>{
      if(!value){
        return Promise.reject('请输入完成时间')
      }
      let index1 = rule.field.split('.')
        let index = Number(index1[1])
      // 与完成时间对比
      if ((value && v_30blfqiwu1.r_7p98nd8hab[index].startTime) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') < dayjs(v_30blfqiwu1.r_7p98nd8hab[index].startTime).format('YYYY-MM-DD hh-mm-ss')) {
        return Promise.reject('计划完成时间不能早于计划开始时间')
      }
      return Promise.resolve()
    }
      }
    ]
    // 新增任务开始时间

    l_8l351x08jp_rules.startTime=[
      {
        required: true,
    trigger: 'blur',
    validator: (rule, value, callback) =>{
      if(!value){
        return Promise.reject('请输入开始时间')
      }
      let index1 = rule.field.split('.')
        let index = Number(index1[1])
      // 与完成时间对比
      if ((value && l_8l351x08jp.o_oh4wy64yk1[index].endTime) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') > dayjs(l_8l351x08jp.o_oh4wy64yk1[index].endTime).format('YYYY-MM-DD hh-mm-ss')) {
        return Promise.reject('开始时间不能晚于计划完成时间')
      }
      return Promise.resolve()
    }
      }
    ]
    // 新增任务结束时间
    l_8l351x08jp_rules.endTime=[
      {
        required: true,
    trigger: 'blur',
    validator: (rule, value, callback) =>{
      if(!value){
        return Promise.reject('请输入结束时间')
      }
      let index1 = rule.field.split('.')
        let index = Number(index1[1])
      // 与完成时间对比
      if ((value && l_8l351x08jp.o_oh4wy64yk1[index].startTime) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') < dayjs(l_8l351x08jp.o_oh4wy64yk1[index].startTime).format('YYYY-MM-DD hh-mm-ss')) {
        return Promise.reject('结束时间不能早于计划开始时间')
      }
      return Promise.resolve()
    }
      }
    ]

    // 编辑里程碑开始时间
    i_ov0jq02ahl_rules.c_u5pspmlac9=[
      {
        required: true,
    trigger: 'blur',
    validator: (rule, value, callback) =>{
      if(!value){
        return Promise.reject('请输入开始时间')
      }
      // 与完成时间对比
      if ((value && i_ov0jq02ahl.b_l8z3pkvbvf) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') > dayjs(i_ov0jq02ahl.b_l8z3pkvbvf).format('YYYY-MM-DD hh-mm-ss')) {
        return Promise.reject('计划开始时间不能晚于计划完成时间')
      }
      return Promise.resolve()
    }
      }
    ]
    // 编辑里程碑完成时间
    i_ov0jq02ahl_rules.b_l8z3pkvbvf=[
      {
        required: true,
    trigger: 'blur',
    validator: (rule, value, callback) =>{
      if(!value){
        return Promise.reject('请输入完成时间')
      }
      // 与开始时间对比
      if ((value && i_ov0jq02ahl.c_u5pspmlac9) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') < dayjs(i_ov0jq02ahl.c_u5pspmlac9).format('YYYY-MM-DD hh-mm-ss')) {
        return Promise.reject('计划完成时间不能早于计划开始时间')
      }
      return Promise.resolve()
    }
      }
    ]

    // 编辑任务开始时间
    p_nq4ej3wmvi_rules.startTime=[
      {
        required: true,
    trigger: 'blur',
    validator: (rule, value, callback) =>{
      if(!value){
        return Promise.reject('请输入开始时间')
      }
      // 与完成时间对比
      if ((value && p_nq4ej3wmvi.endTime) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') > dayjs(p_nq4ej3wmvi.endTime).format('YYYY-MM-DD hh-mm-ss')) {
        return Promise.reject('开始时间不能晚于计划完成时间')
      }
      return Promise.resolve()
    }
      }
    ]
    // 编辑任务结束时间
    p_nq4ej3wmvi_rules.endTime=[
      {
        required: true,
    trigger: 'blur',
    validator: (rule, value, callback) =>{
      if(!value){
        return Promise.reject('请输入结束时间')
      }
      let index1 = rule.field.split('.')
        let index = Number(index1[1])
      // 与完成时间对比
      if ((value && p_nq4ej3wmvi.startTime) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') < dayjs(p_nq4ej3wmvi.startTime).format('YYYY-MM-DD hh-mm-ss')) {
        return Promise.reject('结束时间不能早于计划开始时间')
      }
      return Promise.resolve()
    }
      }
    ]

    watch(
      () => dataConnector_conn_622s372c0e_response?.value,
      ()=>{
     setTimeout(()=>{
      if(dataConnector_conn_622s372c0e_response.value.data.projectStatus==='延期'){
        let tips = document.querySelector('.vid_81dfx97a77')
        console.log(tips,'1323')
        if(tips) tips.style.color = 'red'
        console.log(dataConnector_conn_622s372c0e_response.value.data.projectStatus)
        console.log(dataConnector_conn_622s372c0e_response.value.data)

      }else{
        let tips = document.querySelector('.vid_81dfx97a77')
        if(tips) tips.style.color ='#262626'
      }
     },0)
      },{deep:true})

      watch(
      () => dataConnector_conn_622s372c0e_response?.value,
      ()=>{
        stateLi.userName = dataConnector_conn_622s372c0e_response.value.data.pmName?dataConnector_conn_622s372c0e_response.value.data.pmName:''
      //开关按钮
      let switchBtn = document.querySelector(".vid_s1s7lt3xq1");
      //提交按钮
      let submit = document.querySelector(".vid_bp9e2p5y5u")
      //删除按钮
      let deleteBtn = document.querySelector(".vid_985l6mmauy")
      // 新建项目阶段按钮
      let projectBtn = document.querySelector('.vid_07jjrs8zy0')
      // 项目阶段导入
      let projectInput = document.querySelector('.vid_5p5jxgr6yt')
      // 新增重大风险按钮
      let riskBtn = document.querySelector('.vid_rffdpjgnqu')
      // 需求变更记录新建按钮
      let changeBtn = document.querySelector('.vid_xkvfmrhysc')
      // 新建投诉表扬按钮
      let praiseBtn = document.querySelector('.praise-btn')
      const userInfoStorage = localStorage.getItem('al__USER_INFO')
      const userInfo = JSON.parse(userInfoStorage);
      const userName = userInfo.value.name
      setTimeout(()=>{
        if(dataConnector_conn_622s372c0e_response?.value?.data.delFlag===3){
          if (switchBtn) switchBtn.disabled = true
          if (submit) submit.disabled = true
          if (deleteBtn) deleteBtn.disabled = false
          isTask.value = false
          if (projectBtn) projectBtn.disabled = true
          if (projectInput) projectInput.disabled = true
          if (riskBtn) riskBtn.disabled = true
          if (changeBtn) changeBtn.disabled = true
          if (praiseBtn) praiseBtn.disabled = true
          // 交付编辑项目按钮
          let edit = document.querySelector(".vid_3lbm1rlsmd")
          if (edit) {
            edit.disabled = true
            edit.style.color = 'gray'
          }
        }else if(dataConnector_conn_622s372c0e_response?.value?.data.projectStatusOnOrOff == false ){
          if (switchBtn) switchBtn.disabled = false
          if (submit) submit.disabled = true
          if (deleteBtn) deleteBtn.disabled = true
          isTask.value = false
          if (projectBtn) projectBtn.disabled = true
          if (projectInput) projectInput.disabled = true
          if (riskBtn) riskBtn.disabled = true
          if (changeBtn) changeBtn.disabled = true
          if (praiseBtn) praiseBtn.disabled = true
          // 交付编辑项目按钮
          let edit = document.querySelector(".vid_3lbm1rlsmd")
          if (edit) {
            edit.disabled = true
            edit.style.color = 'gray'
          }
        }else if(dataConnector_conn_622s372c0e_response?.value?.data.instanceId !== null){
          if (switchBtn) switchBtn.disabled = true
          if (submit) submit.disabled = true
          if (deleteBtn) deleteBtn.disabled = true
          isTask.value = false
          if (projectBtn) projectBtn.disabled = true
          if (projectInput) projectInput.disabled = true
          if (riskBtn) riskBtn.disabled = true
          if (changeBtn) changeBtn.disabled = true
          if (praiseBtn) praiseBtn.disabled = true
          // 交付编辑项目按钮
          let edit = document.querySelector(".vid_3lbm1rlsmd")
          if (edit) {
            edit.disabled = true
            edit.style.color = 'gray'
          }
        }
        else if(dataConnector_conn_622s372c0e_response.value.data.pmName !== userName){
          if (switchBtn) switchBtn.disabled = false
          if (submit) submit.disabled = true
          if (deleteBtn) deleteBtn.disabled = true
          isTask.value = true
          if (projectBtn) projectBtn.disabled = true
          if (projectInput) projectInput.disabled = true
          if (riskBtn) riskBtn.disabled = true
          if (changeBtn) changeBtn.disabled = true
          if (praiseBtn) praiseBtn.disabled = true
          // 交付编辑项目按钮
          let edit = document.querySelector(".vid_3lbm1rlsmd")
          if (edit) {
            edit.disabled = true
            edit.style.color = 'gray'
          }

        }else if(!dataConnector_conn_622s372c0e_response?.value?.data.delFlag){
          if (changeBtn) changeBtn.disabled = false
          if (switchBtn) switchBtn.disabled = false
          if (submit) submit.disabled = false
          if (deleteBtn) deleteBtn.disabled = false
          if (projectBtn) projectBtn.disabled = false
          if (projectInput) projectInput.disabled = false
          if (riskBtn) riskBtn.disabled = false
          if (praiseBtn) praiseBtn.disabled = false
          isTask.value = true
        let edit = document.querySelector(".vid_3lbm1rlsmd")
        if (edit) {
          edit.disabled = false
          edit.style.color = '#3875ff'
        }
        }
        else{
          if (changeBtn) changeBtn.disabled = false
          if (switchBtn) switchBtn.disabled = false
          if (submit) submit.disabled = false
          if (deleteBtn) deleteBtn.disabled = false
          if (projectBtn) projectBtn.disabled = false
          if (projectInput) projectInput.disabled = false
          if (riskBtn) riskBtn.disabled = false
          if (praiseBtn) praiseBtn.disabled = false
          isTask.value = true
        let edit = document.querySelector(".vid_3lbm1rlsmd")
        if (edit) {
          edit.disabled = false
          edit.style.color = '#3875ff'
        }
        }
      },500)
      }, {
      deep: true
      }
      )





      const isTask = ref(false)
    const isLeader = ref(false)
    //表扬投诉
    const eventColumns = ref([
      {
        title: '事件描述',
        ellipsis: true,
        dataIndex: 'incidentDescription',
      },
      {
        title: '附件凭证',
        dataIndex: 'attachmentName',
        ellipsis: true,
      },
      {
        title: '事件类型',
        dataIndex: 'eventType',
        width:'100px',
        ellipsis: true,
      },
      {
        title: '状态',
        dataIndex: 'stateStr',
        width:'150px',
        ellipsis: true,
      },
      {
        title: '操作',
        key: 'actions',
        width:'300px',
        dataIndex: 'actions'
      }

    ])
    const eventDataSource  = ref([
    ])

    const modalVisible = ref(false)
    const annexVisible = ref(false)
    const modalTitle = ref('')
    const addOrEdit = ref('')
    const formState = ref(
    	{
    		eventType: '',
    		eventDescription: ''
    	}
    )
    const eventTypeList = ref([
    	{ label: '表扬事件', value: '表扬事件' },
    	{ label: '投诉事件', value: '投诉事件' }
    ])
    const eventEditId = ref('')
    const uploadFlag = ref(true)
    const uploadProps = reactive({
    	uploadFile: (data) => request({
    		url: '/file-storage/api/v1/file/upload',
    		method: 'POST',
    		responseType: 'blob',
    		withCredentials: false,
    		data,
    		timeout: 360000,
    		headers: {},
    	}),

    })
    const 	fileList=ref([])






    let getEventTableData = () => {
    	const params = {
    		projectId: vid_rzym3dfyuw_props?.selected?.singleValue
    	}
    	post(`/solution-ppm/api/v2/built-in-system-ppm/praiseComplaint/queryPpmPraiseComplaintData`, params).then(data => {
    		if (data.code === 200) {
    			eventDataSource.value = data.data

    		}
    	})
    }
    const formStateRef = ref(null)
    // 提交事件
    // 提交事件
    let handlerAddEvent = () => {
    	if (addOrEdit.value === 'add') {
    		formStateRef.value.validate().then(() => {
    			// 调新增接口
    			const params = {
    				incidentDescription: formState.value.eventDescription,
    				eventType: formState.value.eventType,
    				projectId: vid_rzym3dfyuw_props?.selected?.singleValue
    			}
    			post('/solution-ppm/api/v2/built-in-system-ppm/praiseComplaint/creatPraiseComplaint', params).then(data => {
    				if (data.code === 200) {
    					message.success('新建成功')
    					getEventTableData()
    					modalVisible.value = false
    				} else {
    					message.error(data.message)
    				}
    			})
    		})

    	} else {
    		formStateRef.value.validate().then(()=>{
    			// 修改接口
    		const params = {
    			incidentDescription: formState.value.eventDescription,
    			eventType: formState.value.eventType,
    			projectId: vid_rzym3dfyuw_props?.selected?.singleValue,
    			praiseComplaintId: eventEditId.value
    		}
    		post('/solution-ppm/api/v2/built-in-system-ppm/praiseComplaint/updatePraiseComplaint', params).then(data => {
    			if (data.code === 200) {
    				message.success('修改成功')
    				modalVisible.value = false
    				getEventTableData()
    			} else {
    				message.error(data.message)
    			}
    		})
    		})

    	}
    }
    let addEvent = () => {
    	modalVisible.value = true
    	modalTitle.value = '新建表扬投诉事件'
    	addOrEdit.value = 'add'
    }
    let editEvent = (record) => {
    	eventEditId.value = record.praiseComplaintId
    	modalVisible.value = true
    	modalTitle.value = '编辑表扬投诉事件'
    	addOrEdit.value = 'edit'
    	get(`/solution-ppm/api/v2/built-in-system-ppm/praiseComplaint/${record.praiseComplaintId}/queryPraiseComplaintData`).then(data => {
    		if (data.code === 200) {
    			formState.value.eventDescription = data.data.incidentDescription
    			formState.value.eventType = data.data.eventType
    		}
    	})
    }
    let showAttachmentModal = (record) => {
    	if (record.state === 0||record.state === 4||record.state === 1) {
    		annexVisible.value = true
    		eventEditId.value = record.praiseComplaintId
    		uploadFlag.value = true
    		get(`/solution-ppm/api/v2/built-in-system-ppm/praiseComplaint/${record.praiseComplaintId}/queryPraiseComplaintData`).then(data => {
    			if (data.code === 200) {
    				fileList.value = data.data.ppmEnclosureInfoList?data.data.ppmEnclosureInfoList:[]
    			} else {
    				message.error(data.message)
    			}
    		})
    	} else {
        message.info('附件已提交，可点击下载')
    		annexVisible.value = true
    		eventEditId.value = record.praiseComplaintId
    		uploadFlag.value = false
    		get(`/solution-ppm/api/v2/built-in-system-ppm/praiseComplaint/${record.praiseComplaintId}/queryPraiseComplaintData`).then(data => {
    			if (data.code === 200) {
    								fileList.value = data.data.ppmEnclosureInfoList?data.data.ppmEnclosureInfoList:[]
    			} else {
    				message.error(data.message)
    			}
    		})
    	}

    }
    // 删除
    let deleteEvent = record => {
    	const params = {
    		praiseComplaintId: record.praiseComplaintId,
        delFlag:1
    	}
    	post('/solution-ppm/api/v2/built-in-system-ppm/praiseComplaint/updatePraiseComplaint', params).then(data => {
    		if (data.code === 200) {
    			message.success('删除成功')
    			getEventTableData()
    		} else {
    			message.error(data.message)
    		}
    	})
    }
    // 提交按钮
    let submitPraise = (record)=>{
      const params = {
        praiseComplaintId:record.praiseComplaintId
      }
      post('/solution-ppm/api/v2/built-in-system-ppm/praiseComplaint/submit',params).then(data=>{
        if(data.code === 200){
          message.success('提交成功')
          getEventTableData()
        }else{
          message.error(data.message)
        }
      })
    }
    // 提交附件
    let handlerAddAnnex = () => {
    	const params = {
    		praiseComplaintId: eventEditId.value,
    		ppmEnclosureInfoList: fileList.value
    	}
    	post('/solution-ppm/api/v2/built-in-system-ppm/praiseComplaint/updatePraiseComplaint', params).then(data => {
    		if (data.code === 200) {
    			message.success('上传成功')
    			annexVisible.value = false
    			getEventTableData()
    		} else {
    			message.error(data.message)
    		}
    	})
    }
    let handleCancel = () => {
    	annexVisible.value = false
    }
    let resetForm = ()=>{
    	formState.value.eventDescription=''
    	formState.value.eventType=''
    }










     const projectId = ref()

          const pageType = 'deliver'
          let apiMap = {
            default: '',
            plat: '',
            market: '',
            deliver: ''
          }

          if (import.meta.env?.VITE_APP_ID === 'app_10000067') {
            setTimeout(() => {
              projectId.value = 82
            })
          } else {
            try {
              watch(
                () => vid_rzym3dfyuw_props.selected.singleValue,
                () => {
                  if (vid_rzym3dfyuw_props.selected.singleValue) {
                    projectId.value = vid_rzym3dfyuw_props.selected.singleValue
                  }
                }
              )
            } catch (error) {
            }
          }
          const stateLi = reactive({
            userName:'',
            tableLoading: false,
            taskList: [],
            taskParticipantList: [],
            milepostList: [],
            filterLi: {
              taskName: '',
              taskParticipantStr: undefined,
              endTime: '',
              taskOwner: '',
              taskStatusOnOrOff: 'true',
              taskStatusList: [],
              stateInput: '',
              priorityStr: '',
              milepostId: '',
              milepostId: ''
            },
            columns: [
            {
                  title: '项目阶段',
                  dataIndex: 'milepostName',
                            resizable: true,
                  ellipsis: true,
                  width: '250px',
                  fixed: 'left',
                  align: 'left',
                  customCell: ({ rowSpan }) => {
                    return {
                      rowSpan: rowSpan
                    }
                  }
                },
                {
                  title: '序号',
                  dataIndex: 'taskIndex',
                  resizable: true,
                  ellipsis: true,
                  width: '70px',
                  fixed: 'left',
                  align: 'left',
                  customCell: ({ level, nodeType }) => {
                    return {
                      style: {
                        paddingLeft: `${(level + 1) * 15}px`,
                        color: `${nodeType === 'MENU' ? '#3875ff' : ''}`
                      }
                    }
                  }
                },
                {
                  title: '任务名称',
                  dataIndex: 'taskName',
                  ellipsis: true,
                  resizable: true,
                  width: '250px',
                  fixed: 'left',
                  align: 'left',
                  customCell: ({ level, nodeType }) => {
                    return {
                      style: {
                        paddingLeft: `${(level + 1) * 20}px`,
                        color: `${nodeType === 'MENU' ? '#3875ff' : ''}`
                      }
                    }
                  }
                },
                {
                  title: '任务状态',
                  dataIndex: 'taskStatus',
                  resizable: true,
                  ellipsis: false,
                  width: '140px',
                  align: 'center'
                },
                {
                title: '验收标准',
                dataIndex: 'acceptanceCriteria',
                resizable: true,
                ellipsis: true,
                width: '200px',
                align: 'center'
              },
                        {
                title: '甲方工作事项',
                dataIndex: 'taskRemarks',
                resizable: true,
                ellipsis: true,
                width: '200px',
                align: 'center'
              },
              {
                  title: '附件',
                  dataIndex: 'attachment',
                  resizable: true,
                  ellipsis: true,
                  width: '200px',
                  align: 'center'
                },
                {
                  title: '任务负责人',
                  dataIndex: 'taskOwner',
                  resizable: true,
                  ellipsis: true,
                  width: '140px',
                  align: 'center'
                },
                {
                  title: '审核员',
                  dataIndex: 'assessorName',
                  resizable: true,
                  ellipsis: true,
                  width: '140px',
                  align: 'center'
                },

                {
                  title: '任务执行人',
                  resizable: true,
                  dataIndex: 'taskParticipantStr',
                  ellipsis: true,
                  width: '140px',
                  align: 'center'
                },
                {
                  title: '计划开始',
                  dataIndex: 'startTime',
                  resizable: true,
                  ellipsis: true,
                  width: '140px',
                  align: 'center'
                },
                {
                  title: '实际开始',
                  dataIndex: 'actualStarTime',
                  resizable: true,
                  ellipsis: true,
                  width: '140px',
                  align: 'center'
                },
                {
                  title: '计划完成',
                  dataIndex: 'endTime',
                  ellipsis: true,
                  width: '120px',
                  resizable: true,
                  align: 'center'
                },
                {
                  title: '	实际完成',
                  dataIndex: 'taskFinishTime',
                  ellipsis: true,
                  resizable: true,
                  width: '120px',
                  align: 'center'
                },
              
                {
                  title: '审批状态',
                  dataIndex: 'approvalStatus',
                  resizable: true,
                  ellipsis: true,
                  width: '200px',
                  align: 'center'
                },
                {
                  title: '优先级',
                  dataIndex: 'priorityStr',
                  resizable: true,
                  ellipsis: true,
                  width: '150px',
                  align: 'center'
                },
                {
                  title: '未关闭风险数量',
                  dataIndex: 'unclosedRiskNumber',
                  resizable: true,
                  ellipsis: true,
                  width: '160px',
                  align: 'center'
                },
                {
                  title: '风险数量',
                  dataIndex: 'riskNumber',
                  resizable: true,
                  ellipsis: true,
                  width: '160px',
                  align: 'center'
                },
                {
                  title: '任务编码',
                  dataIndex: '',
                  ellipsis: true,
                  resizable: true,
                  width: '160px',
                  align: 'center'
                },

                {
                  title: '计划工时',
                  dataIndex: 'workingHours',
                  resizable: true,
                  ellipsis: true,
                  width: '100px',
                  align: 'center'
                },
                {
                  title: '实际工时',
                  dataIndex: 'actualWorkHours',
                  resizable: true,
                  ellipsis: true,
                  width: '100px',
                  align: 'center'
                },
                {
                  title: '工时投入状态',
                  dataIndex: 'stateInput',
                  resizable: true,
                  ellipsis: true,
                  width: '200px',
                  align: 'center'
                },

                {
                  title: '任务类型',
                  dataIndex: 'taskType',
                  resizable: true,
                  ellipsis: true,
                  width: '200px',
                  align: 'center'
                },
                   
                {
                  title: '备注',
                  dataIndex: 'description',
                  resizable: true,
                  ellipsis: true,
                  width: '100px',
                  align: 'center'
                },
                
                {
                  title: '任务上下线',
                  dataIndex: 'taskStatusOnOrOff',
                  resizable: true,
                  ellipsis: true,
                  width: '120px',
                  align: 'center'
                },
                {
                  title: '依赖任务',
                  dataIndex: 'taskDependency',
                  resizable: true,
                  ellipsis: true,
                  width: '100px',
                  align: 'center'
                },
                {
                  title: '操作',
                  dataIndex: 'operation',
                  width: '430px',
                  align: 'center'
                }
              ],


            dataList: [],

            spinning: false,
            visible: false,
            ppmTaskFromList: [],
            parentListMap: {},
            visibleNotes: false,
            notesColumns: [
              { title: '备注内容', dataIndex: 'description', align: 'center' },
              { title: '提交人', dataIndex: 'createdBy', align: 'center' },
              { title: '提交时间', dataIndex: 'submissionTime', align: 'center' }
            ],
            noteData: [],
            visibleRisk: false,
            riskList: [],
            riskColumns: [
              { title: '风险描述', dataIndex: 'riskDescription', width: '300px', align: 'center' },
              { title: '解决方案', dataIndex: 'solution', align: 'center' },
              { title: '风险状态', dataIndex: 'riskState', align: 'center' },
              { title: '提交人', dataIndex: 'reportedBy', align: 'center' },
              { title: '提交时间', dataIndex: 'dailyDate', align: 'center' },
              { title: '任务', dataIndex: 'taskName', align: 'center' },
              { title: '事项', dataIndex: 'riskDescription', width: '300px', align: 'center' },
              { title: '风险关闭备注', dataIndex: 'riskRemarks', align: 'center' },
              { title: '操作', dataIndex: 'operation', align: 'center' }
            ],
            closeVisible: false,
            visibleFile: false,
            fileList: [],
            okVisible: false,
            projectManager: false
          })

          const btnLoading = ref(false)
          const taskLeader = JSON.parse(userInfoStorage)
   const ppmTaskFromListItem = {
              taskName: undefined,
              milepostId: undefined,
              taskDependency: undefined,
              priority: 'HIGH',
              taskOwner: taskLeader.value.name,
              taskType: '主任务',
              assessorName: taskLeader.value.name,
              startTime: undefined,
              endTime: undefined,
              allTime:[],
              taskParticipantList: [],
              description: undefined,
              workingHours: undefined,
              output: '否',
              parentId: undefined,
              taskIndex: undefined,
              reasonsChange: undefined,
              nodeType: 'TASK',
                    // 验收标准
            acceptanceCriteria:undefined,
            // 验收标准
            taskRemarks:undefined
            }
          function handlerAddFormItem() {
            stateLi.ppmTaskFromList.push({ ...ppmTaskFromListItem })
          }
     function handleTaskResizeColumn(w, col){
          col.width = w;
        }
          const scrollX = stateLi.columns.reduce((pre, cur) => {
            return parseInt(pre.width) + parseInt(cur.width)
          }, {})

          function formatTableData(data, level = 0) {
            if (!data) {
              return []
            }
            const newData = []
            data.forEach(item => {
              const {
                projectSwitch,
                taskStatusOnOrOff,
                taskStatus,
                operationFlag,
                delFlag,
                attachmentStatus,
                uploadPermission,
                finishPermission,
                projectManager,
                children
              } = item

                item.level = level
                const disabledOkBtn =
                  !finishPermission ||
                  projectSwitch === 'false' ||
                  attachmentStatus === 'false' ||
                  operationFlag === 1 ||
                  taskStatusOnOrOff === false ||
                  !(!['审批中', '完成', '延期完成'].includes(taskStatus) && delFlag === 0 && !children?.length)

                const disabledMenuEditBtn = !projectManager
               const disabledEditBtn =
    (!projectManager ||
      projectSwitch === 'false' ||
      taskStatusOnOrOff === false ||
      taskStatus === '完成' ||
      taskStatus === '延期完成') &&
    !(uploadPermission || projectManager);


                const disabledMenuDelBtn = !projectManager || children?.length > 0

                const disabledDelBtn =
    (!projectManager ||
      projectSwitch === 'false' ||
      taskStatusOnOrOff === false ||
      taskStatus === '完成' ||
      taskStatus === '延期完成' ||
      taskStatus === '审批中' ||
      delFlag === 2 ||
      (children?.length > 0)) &&
    !(uploadPermission || projectManager);


    const disabledRiskBtn =
    (projectSwitch === 'false' ||
      taskStatusOnOrOff === false ||
      delFlag === 2 ||
      !projectManager) &&
    !(uploadPermission || projectManager);


    const disabledFileBtn =
    (!projectManager ||
      projectSwitch === 'false' ||
      taskStatusOnOrOff === false ||
      taskStatus === '完成' ||
      taskStatus === '延期完成' ||
      operationFlag === 1 ||
      taskStatus === '审批中' ||
      delFlag === 2) &&
    !(uploadPermission || projectManager);


                const disabledNoteBtn = false


              const itemChildren = item.children
              item.children = null
              newData.push({
                ...item,
                disabledOkBtn,
                disabledEditBtn,
                disabledDelBtn,
                disabledRiskBtn,
                disabledFileBtn,
                disabledNoteBtn
              })
              if (itemChildren?.length) {
                newData.push(...formatTableData(itemChildren, level + 1))
              }
            })
            return newData
          }
          function groupData(data) {
            let currentMilepostName = ''
            return data.map((item, index) => {
              if (currentMilepostName !== item.milepostName) {
                currentMilepostName = item.milepostName
                let rowSpan = 0
                for (let i = 0; i < data.length; i++) {
                  if (i >= index) {
                    if (currentMilepostName === data[i].milepostName) {
                      rowSpan += 1
                    } else {
                      break
                    }
                  }
                }
                item.rowSpan = rowSpan
              } else {
                item.rowSpan = 0
              }

              return item
            })
          }

          function getTableData() {
            stateLi.tableLoading = true
            apiMap = {
              default: '/solution-ppm/api/v2/built-in-system-ppm/refactoring_task/list',
              plat: '/solution-ppm/api/v2/built-in-system-ppm/refactoring_task/list',
              market: '/solution-ppm/api/v2/built-in-system-ppm/search',
              deliver: '/solution-ppm/api/v2/built-in-system-ppm/delivery_task/search'
            }
            post(apiMap[pageType], {
              ...stateLi.filterLi,
              taskParticipantStr: stateLi.filterLi.taskParticipantStr?.join(','),
              projectId: projectId.value
            })
              .then(({ data }) => {
                stateLi.dataList = groupData(formatTableData(data))
              })
              .finally(() => {
                stateLi.tableLoading = false
              })
          }

          const resetSearch = () => {
            stateLi.filterLi = {
              taskName: '',
              taskParticipantStr: undefined,
              endTime: '',
              taskOwner: '',
              taskStatusOnOrOff: 'true',
              taskStatusList: [],
              stateInput: '',
              priorityStr: '',
              milepostId: '',
              milepostId: ''
            }
            getTableData()
          }

          function getTaskList() {
            apiMap = {
              default: '/solution-ppm/api/v2/built-in-system-ppm/task/list',
              plat: '/solution-ppm/api/v2/built-in-system-ppm/v2/platform/task/list',
              market: '/solution-ppm/api/v2/built-in-system-ppm/internalAndMarketTask/list',
              deliver: '/solution-ppm/api/v2/built-in-system-ppm/delivery_task/list'
            }
            post(apiMap[pageType], {
              pageSize: 10000,
              pageNo: 1,
              projectId: projectId.value,
              taskStatusOnOrOff: '全部'
            }).then(({ data }) => {
              stateLi.taskList = data?.dataList?.filter(item => item.nodeType === 'TASK') || []
            })
          }

          function getTaskParticipantList() {
            apiMap = {
              default: '/base/api/v1/user/search/basic',
              plat: '/base/api/v1/user/search/basic',
              market: '/base/api/v1/user/search/basic',
              deliver: '/base/api/v1/user/search/basic'
            }
            post(apiMap[pageType], {
              pageSize: 10000,
              pageNo: 1,
              projectId: projectId.value
            }).then(({ data }) => {
              stateLi.taskParticipantList = data.content
            })
          }

          function getMilepostList() {
            apiMap = {
              default: `/solution-ppm/api/v2/built-in-system-ppm/milepost/query/milepost/name/${projectId.value}`,
              plat: `/solution-ppm/api/v2/built-in-system-ppm/milepost/query/milepost/name/${projectId.value}`,
              market: `/solution-ppm/api/v2/built-in-system-ppm/internalAndMarketMilepost/query/milepost/name/${projectId.value}`,
              deliver: `/solution-ppm/api/v2/built-in-system-ppm/delivery_milepost/${projectId.value}/milepost_name/list`
            }
            get(apiMap[pageType]).then(data => {
              stateLi.milepostList = data.data.dataList
            })
          }

          function getIsProjectManager() {
            get(`/solution-ppm/api/v2/built-in-system-ppm/delivery_task/${projectId.value}/check_project_manager`).then(
              ({ data }) => {
                stateLi.projectManager = data
              }
            )
          }

          function init() {
            getTableData()
            getMilepostList()
            getIsProjectManager()
            //getTaskParticipantList()
          }

          const formRef = ref()

          const current = ref({})
          const closeCurrent = ref({
            dailyItemId: undefined,
            riskRemarks: ''
          })
          const closeFormRef = ref()

          watch(
            () => stateLi.visible,
            () => {
              if (!stateLi.visible) {
                current.value = {}
              }
            }
          )

          watch(
            () => stateLi.visibleFile,
            () => {
              if (!stateLi.visibleFile) {
                current.value = {}
              }
            }
          )

          function handlerShowRisks(record, type = '全部') {
            stateLi.visibleRisk = true
            apiMap = {
              default: `/solution-ppm/api/v2/built-in-system-ppm/daily/${record.taskId}/queryRiskList`,
              plat: `/solution-ppm/api/v2/built-in-system-ppm/daily/${record.taskId}/queryRiskList`,
              market: `/solution-ppm/api/v2/built-in-system-ppm/daily/${record.taskId}/queryRiskList`,
              deliver: `/solution-ppm/api/v2/built-in-system-ppm/daily/${record.taskId}/${type}/queryRiskList`
            }
            get(apiMap[pageType]).then(({ dataList }) => {
              stateLi.riskList = dataList
            })
          }

          function handlerShowUpdate(record) {
            current.value = record
            stateLi.visibleFile = true
            apiMap = {
              default: `/solution-ppm/api/v2/built-in-system-ppm/task/${record.taskId}/queryAttachment`,
              plat: `/solution-ppm/api/v2/built-in-system-ppm/v2/platform/task/attachment/${record.taskId}`,
              market: `/solution-ppm/api/v2/built-in-system-ppm/internalAndMarketTask/${record.taskId}/queryAttachment`,
              deliver: `/solution-ppm/api/v2/built-in-system-ppm/delivery_task/${record.taskId}/queryAttachment`
            }
            get(apiMap[pageType]).then(({ data }) => {
              stateLi.fileList = data?.attachment ? JSON.parse(data.attachment) : []
            })
          }

          function customRow(record, index) {
            return {
              style: {
                cursor: 'pointer'
              }
            }
          }

          function changeTaskStatusOnOrOff(record) {
            const reasonsChange = ref('')
            Modal.confirm({
              title: '变更原因',
              icon: null,
              content: h(Textarea, {
                value: reasonsChange,
                ['onUpdate:value']: value => {
                  reasonsChange.value = value
                }
              }),
              onOk() {
                record.taskStatusOnOrOff = !record.taskStatusOnOrOff
                apiMap = {
                  default: '/solution-ppm/api/v2/built-in-system-ppm/task/taskStatusOnOrOff',
                  plat: '/solution-ppm/api/v2/built-in-system-ppm/task/taskStatusOnOrOff',
                  market: '/solution-ppm/api/v2/built-in-system-ppm/internalAndMarketTask/taskStatusOnOrOff',
                  deliver: '/solution-ppm/api/v2/built-in-system-ppm/delivery_task/taskStatusOnOrOff'
                }
                post(apiMap[pageType], {
                  taskStatusOnOrOff: String(record.taskStatusOnOrOff),
                  taskId: record.taskId,
                  reasonsChange: reasonsChange.value
                }).then(({ code, message: errorMsg }) => {
                  if (code !== 200) {
                    message.error(errorMsg || '操作失败')
                  } else {
                    message.info('提交成功!')
                  }
                  getTableData()
                })
              },
              onCancel() {
                Modal.destroyAll()
              }
            })
          }

          function handlerMilepostIdChange(index, parentId = undefined) {
            const record = stateLi.ppmTaskFromList[index]
            record.parentId = parentId
            apiMap = {
              default: `/solution-ppm/api/v2/built-in-system-ppm/refactoring_task/tree/${record.milepostId}`,
              plat: `/solution-ppm/api/v2/built-in-system-ppm/refactoring_task/tree/${record.milepostId}`,
              market: `/solution-ppm/api/v2/built-in-system-ppm/refactoring_task/tree/${record.milepostId}`,
              deliver: `/solution-ppm/api/v2/built-in-system-ppm/delivery_task/parent_tree/${record.milepostId}/${
                current.value.taskId || 0
              }`
            }
            get(apiMap[pageType]).then(({ data }) => {
              stateLi.parentListMap[index] = data
            })
          }

          function handlerDeleteFormItem(index) {
            stateLi.ppmTaskFromList.splice(index, 1)
            const data = {}
            for (let k in stateLi.parentListMap) {
              if (k < index) {
                data[k] = stateLi.parentListMap[k]
              } else if (k > index) {
                data[k - 1] = stateLi.parentListMap[k]
              }
            }
            stateLi.parentListMap = data
          }


          function handlerAdd() {
            if(isTemplate.value===true){
              message.info('模板项目不能创建任务')
            }else{
              stateLi.ppmTaskFromList = [{ ...ppmTaskFromListItem }]
            getPopleList()
            stateLi.visible = true
            }

          }
          const taskPeopleList = ref([])
          function getPopleList(){
          post(`/solution-ppm/api/v2/built-in-system-ppm/task/getTopUser/${projectId.value}`).then(data=>{
            taskPeopleList.value = data.data.map(item=>{
      return {
      label:item,
        value:item
      }
      })
          })
          }
         function handlerCancel(){
          stateLi.visible = false
          ppmTaskFromListItem.taskParticipantList = []
         }
          function handlerAddPeople(name,index){
            console.log(name,'人名')
            console.log(index,'顺序')
            if(stateLi.ppmTaskFromList[index].taskParticipantList.indexOf(name) !== -1){
             stateLi.ppmTaskFromList[index].taskParticipantList=stateLi.ppmTaskFromList[index].taskParticipantList.filter(item => item !== name);
            }else{
              stateLi.ppmTaskFromList[index].taskParticipantList.push(name)
            }

          }
          function handlerSubmit() {
            if (!stateLi.ppmTaskFromList.length) {
              return message.warning('请添加新任务!')
            }
            formRef.value.validate().then(data => {
              btnLoading.value = true
              apiMap = {
                default: `/solution-ppm/api/v2/built-in-system-ppm/task/${projectId.value}/creat`,
                plat: `/solution-ppm/api/v2/built-in-system-ppm/v2/platform/task/${projectId.value}`,
                market: `/solution-ppm/api/v2/built-in-system-ppm/internalAndMarketTask/${projectId.value}/creat`,
                deliver: `/solution-ppm/api/v2/built-in-system-ppm/delivery_task/${projectId.value}/creat`
              }
              let params = Object.values(stateLi.ppmTaskFromList).map(item => ({
  	...item,
  	startTime: item.allTime[0],
  	endTime: item.allTime[1]
    }));
              post(apiMap[pageType], {
                dataList: params
              })
                .then(({ message: errMsg, code }) => {
                 if (code === 200) {
                    message.success('操作成功')
                    stateLi.visible = false
                    ppmTaskFromListItem.taskParticipantList = []
                    getTableData()
                  }else{
                  message.error(errMsg)
                  }
                })
                .finally(() => {
                  btnLoading.value = false
                })
            })
          }

          function handlerUpdate() {
            formRef.value.validate().then(() => {
              btnLoading.value = true
              apiMap = {
                default: '/solution-ppm/api/v2/built-in-system-ppm/task/update',
                plat: '/solution-ppm/api/v2/built-in-system-ppm/v2/platform/task',
                market: '/solution-ppm/api/v2/built-in-system-ppm/internalAndMarketTask/update',
                deliver: '/solution-ppm/api/v2/built-in-system-ppm/delivery_task/update'
              }
              const api = pageType === 'plat' ? put : post
              let newData = {
  				...current.value
  			  }
  			  newData.startTime = current.value.allTime[0]
  			  newData.endTime = current.value.allTime[1]
              api(apiMap[pageType], { ...newData, projectId: projectId.value })
                .then(({ message: errMsg, code }) => {
                  stateLi.visible = false
                  if (code !== 200) {
                    message.error(errMsg)
                  }else{
                    message.success('修改成功')
                  }
                  getTableData()
                })
                .finally(() => {
                  btnLoading.value = false
                })
            })
          }

          function handlerRestore() {
            formRef.value.validate().then(() => {
              btnLoading.value = true
              post('/solution-ppm/api/v2/built-in-system-ppm/delivery_task/recovery', {
                ...current.value,
                projectId: projectId.value
              })
                .then(({ message: errMsg, code }) => {
                  stateLi.visible = false
                  if (code !== 200) {
                    message.error(errMsg || '操作失败')
                  }else{
                    message.success('操作成功')
                  }
                  getTableData()
                })
                .finally(() => {
                  btnLoading.value = false
                })
            })
          }

          function beforeSubmit() {
            if (current.value.taskId) {
              if (current.value.restore) {
                handlerRestore()
              } else {
                handlerUpdate()
              }
            } else {
              handlerSubmit()
            }
          }

          function handlerShowNotes(record) {
            stateLi.visibleNotes = true
            apiMap = {
              default: '/solution-ppm/api/v2/built-in-system-ppm/description/queryDescription',
              plat: '/solution-ppm/api/v2/built-in-system-ppm/description/queryDescription',
              market: '/solution-ppm/api/v2/built-in-system-ppm/description/queryDescription',
              deliver: '/solution-ppm/api/v2/built-in-system-ppm/description/queryDescription'
            }
            post(apiMap[pageType], {
              sourceId: record.taskId,
              descriptionType: 'TASK'
            }).then(({ data }) => {
              stateLi.noteData = data
            })
          }

          const editParentList = ref([])

          function handlerEdit(record, restore = undefined) {
            apiMap = {
              default: `/solution-ppm/api/v2/built-in-system-ppm/task/${record.taskId}}`,
              plat: `/solution-ppm/api/v2/built-in-system-ppm/v2/platform/task/${record.taskId}`,
              market: `/solution-ppm/api/v2/built-in-system-ppm/internalAndMarketTask/${record.taskId}}`,
              deliver: `/solution-ppm/api/v2/built-in-system-ppm/delivery_task/${record.taskId}`
            }
            get(apiMap[pageType]).then(({ data }) => {
              let oldData = data || {}
        console.log(oldData,'dasdads')
              current.value = {
                ...oldData,
                allTime:[oldData.startTime,oldData.endTime],
                parentId: oldData?.parentId ? oldData.parentId : undefined,
                taskId: record.taskId,
                restore
              }
              stateLi.ppmTaskFromList = [current.value]
              handlerMilepostIdChange(0, data?.parentId)
            })
            apiMap = {
              default: `/solution-ppm/api/v2/built-in-system-ppm/refactoring_task/tree/${record.milepostId}`,
              plat: `/solution-ppm/api/v2/built-in-system-ppm/refactoring_task/tree/${record.milepostId}`,
              market: `/solution-ppm/api/v2/built-in-system-ppm/refactoring_task/tree/${record.milepostId}`,
              deliver: `/solution-ppm/api/v2/built-in-system-ppm/refactoring_task/tree/${record.milepostId}`
            }
            get(apiMap[pageType]).then(({ data }) => {
              editParentList.value = data
            })
            getPopleList()
            stateLi.visible = true
          }

          function handlerDelete(record) {
            if(isTemplate.value===true){
              message.info('模板项目不能删除任务')
            }else{
              apiMap = {
              default: '/solution-ppm/api/v2/built-in-system-ppm/task/approveDeletePpmPpmTaskByTaskId',
              plat: '/solution-ppm/api/v2/built-in-system-ppm/v2/platform/task/approve',
              market: '/solution-ppm/api/v2/built-in-system-ppm/internalAndMarketTask/approveDeleteTaskByTaskId',
              deliver: '/solution-ppm/api/v2/built-in-system-ppm/delivery_task/approveDeleteTaskByTaskId'
            }

            del(apiMap[pageType], {
              data: {
                plName: record.plName,
                taskId: record.taskId
              }
            }).then(({ code, message: errorMsg }) => {
              if (code === 200) {
                message.success('提交成功')
                getTableData()
              } else {
                message.error(errorMsg || '删除失败')
              }
            })
            }

          }

          watch(
            () => stateLi.okVisible,
            () => {
              if (!stateLi.okVisible) {
                current.value = {}
              }
            }
          )

          const ppmCheckList = ref([])
          const ppmCheckedList = ref([])

          const ppmCheckedListLen = ref(0)

          function beforeOk(record) {
            console.log(record,'kjgkhjh')
    // 交付
    if (record.finishPermission == false || record.operationFlag === 1) {
      message.error('非该任务任务负责人')
    } else if (record.attachmentStatus === 'false') {
      message.error('该任务未上传附件，请上传附件后重试')
    } else if (record.taskStatusOnOrOff == false) {
      message.error('只有开启/上线的任务才能完成任务')
    } else if (record.projectSwitch == 'false') {
      message.error('只有项目开启状态下的任务才能完成')
    } else if ((record.taskStatus === '审批中' || record.taskStatus === '延期完成' || record.taskStatus === '完成')&& record.delFlag === 0) {
      message.error(`任务状态为${record.taskStatus}的任务无法进行完成操作`)
    } else if (record.isRiskOrNo == true) {
      message.error('该任务包含风险，请关闭风险后重试')
    } else {
      current.value = record
      apiMap = {
          default: '/solution-ppm/api/v2/built-in-system-ppm/checklist//queryPpmMilepostChecklistMap',
          plat: '/solution-ppm/api/v2/built-in-system-ppm/checklist//queryPpmMilepostChecklistMap',
          market: '/solution-ppm/api/v2/built-in-system-ppm/checklist//queryPpmMilepostChecklistMap',
          deliver: '/solution-ppm/api/v2/built-in-system-ppm/checklist//queryPpmMilepostChecklistMap'
      }
      post(apiMap[pageType], {
          milepostId: current.value.milepostId
      }).then(({
          ppmCheckListMap
      }) => {
          const data = []
          let len = 0
          for (let key in ppmCheckListMap) {
              len += ppmCheckListMap[key].length || 0
              data.push({
                  name: key,
                  value: ppmCheckListMap[key]
              })
          }

          ppmCheckedListLen.value = len
          ppmCheckedList.value = []
          ppmCheckList.value = data
          stateLi.okVisible = true
      })
    }

          }

          function handlerOk() {
            stateLi.btnLoading = true
            apiMap = {
              default: '/solution-ppm/api/v2/built-in-system-ppm/task/taskCompletionApprovalFlow',
              plat: '/solution-ppm/api/v2/built-in-system-ppm/v2/platform/task/status',
              market: '/solution-ppm/api/v2/built-in-system-ppm/internalAndMarketTask/taskCompletionApprovalFlow',
              deliver: '/solution-ppm/api/v2/built-in-system-ppm/delivery_task/taskCompletionApprovalFlow'
            }
            const api = pageType === 'plat' ? put : post
            api(apiMap[pageType], {
              plName: current.value.plName,
              taskId: current.value.taskId
            }).then(({ code, message: errorMsg }) => {
              stateLi.btnLoading = false
              if (code === 200) {
                message.success('操作成功')
                stateLi.okVisible = false
                getTableData()
              } else {
                message.error(errorMsg || '操作失败')
              }
            })
          }

          function handlerBeforeClose(record) {
            closeCurrent.value = {
              dailyItemId: record.dailyItemId,
              riskRemarks: '',
              taskId: record.taskId
            }
            stateLi.closeVisible = true
          }

          function handlerClose() {
            closeFormRef.value.validate().then(() => {
              btnLoading.value = true
              apiMap = {
                default: '/solution-ppm/api/v2/built-in-system-ppm/daily/updateRiskState',
                plat: '/solution-ppm/api/v2/built-in-system-ppm/daily/updateRiskState',
                market: '/solution-ppm/api/v2/built-in-system-ppm/daily/updateRiskState',
                deliver: '/solution-ppm/api/v2/built-in-system-ppm/daily/updateRiskState'
              }
              post(apiMap[pageType], closeCurrent.value)
                .then(({ code, message: errMsg }) => {
                  if (code === 200) {
                    stateLi.closeVisible = false
                    handlerShowRisks(closeCurrent.value)
                    message.success('操作成功')
                  } else {
                    message.warning(errMsg || '操作失败')
                  }
                })
                .finally(() => {
                  btnLoading.value = false
                })
            })
          }

          function handlerUpload(file) {
            const data = new FormData()
            data.append('file', file)
            apiMap = {
              default: '/file-storage/api/v1/file/upload',
              plat: '/file-storage/api/v1/file/upload',
              market: '/file-storage/api/v1/file/upload',
              deliver: '/file-storage/api/v1/file/upload'
            }
            post(apiMap[pageType], data).then(({ data: { fullUrl } }) => {
              if (data) {
                stateLi.fileList = [
                  ...stateLi.fileList,
                  {
                    uid: file.uid,
                    lastModified: file.lastModified,
                    name: file.name,
                    size: file.size,
                    type: file.type,
                    status: 'done',
                    url: fullUrl
                  }
                ]
              }
            })
            return false
          }

          function handleRemove(file) {
            stateLi.fileList = stateLi.fileList.filter(item => item.uid !== file.uid)
          }

          function handlerUpdateFile() {
            stateLi.btnLoading = true
            apiMap = {
              default: '/solution-ppm/api/v2/built-in-system-ppm/task/attachmentUploading',
              plat: '/solution-ppm/api/v2/built-in-system-ppm/v2/platform/task/attachment',
              market: '/solution-ppm/api/v2/built-in-system-ppm/internalAndMarketTask/attachmentUploading',
              deliver: '/solution-ppm/api/v2/built-in-system-ppm/delivery_task/attachmentUploading'
            }
            post(apiMap[pageType], {
              ppmEnclosureInfoList: stateLi.fileList,
              taskId: current.value.taskId
            }).then(() => {
              stateLi.btnLoading = false
              stateLi.visibleFile = false
              message.success('操作成功')
              getTableData()
            })
          }

          function ppmCheckedListChange(value) {
            if (ppmCheckedList.value.includes(value)) {
              ppmCheckedList.value = ppmCheckedList.value.filter(item => item !== value)
            } else {
              ppmCheckedList.value.push(value)
            }
          }

          function getModalContainer() {
            return window.document.querySelector('.my-page')
          }

    function handlerDownload({ url, name }) {
            function downBlob(blob) {
              const downloadElement = document.createElement('a')
              const href = window.URL.createObjectURL(blob) // 创建下载的链接
              downloadElement.href = href
              downloadElement.download = name // 下载后文件名
              document.body.appendChild(downloadElement)
              downloadElement.click() // 点击下载
              document.body.removeChild(downloadElement) // 下载完成移除元素
              window.URL.revokeObjectURL(href)
            }
            const data = new FormData()
            data.append('path', url)
            post('/solution-ppm/api/v2/built-in-system-ppm/delivery_task/downloadFile', data, {
              responseType: 'blob',
              headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
              }
            }).then(blob => {
              downBlob(blob)
            })
          }

    // TODO:任务导出方法
    function downloadExcel (response, name)  {
      const blob = new Blob([response], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8' });
      const downloadElement = document.createElement('a');
      const href = window.URL.createObjectURL(blob);// 创建下载的链接
      downloadElement.href = href;
      downloadElement.download = name; // 下载后文件名
      document.body.appendChild(downloadElement);
      downloadElement.click(); // 点击下载
      document.body.removeChild(downloadElement); // 下载完成移除元素
      window.URL.revokeObjectURL(href);
      return href;
    }
    function handlerTaskExport(){
      //可能会变
      post(`/solution-ppm/api/v2/built-in-system-ppm/delivery_task/export/${projectId.value}`, null, { responseType: 'arraybuffer', }).then(res => {
        downloadExcel(res, '任务.xlsx')
      })
    }
    // 任务导出方法
    // TODO:任务导入方法
    function handlerTaskImport(file){
      //可能会变
      const data = new FormData()
      data.append('file', file)
      post(`/solution-ppm/api/v2/built-in-system-ppm/delivery_task/upload/${projectId.value}`, data).then(({message: errorMsg, code})=>{
        if (code !== 200) {
          message.error(errorMsg)
        }else{
        	message.success('导入成功')
        }
          // 成功后刷新列表
        getTableData()
      })
      return false
    }
    // 任务导入方法

     function validateEndTime({ startTime, endTime }) {
            if (startTime && endTime) {
              const time1 = new Date(startTime).getTime()
              const time2 = new Date(endTime).getTime()
              if (time1 > time2) {
                return Promise.reject('任务结束日期必须大于等于任务开始日期')
              }
            }
            return Promise.resolve()
          }

    //从项目参与人中取人名让任务用
    const peopleList = ref([])

    watch(
    () => dataConnector_conn_622s372c0e_response?.value,
    ()=>{
    if(dataConnector_conn_622s372c0e_response?.value?.data?.projectStakeholdersName){
    peopleList.value = dataConnector_conn_622s372c0e_response.value.data.projectStakeholdersName.split(',')
    peopleList.value = peopleList.value.map(item=>{
    return {
    label:item,
      value:item
    }
    })

    }
    },{deep:true})


    const isTemplate = ref(false)
    watch(
      () => dataConnector_conn_622s372c0e_response?.value,
      () => {
       setTimeout(()=>{
              // 新建项目阶段按钮
  let projectBtn = document.querySelector('.vid_07jjrs8zy0')
        console.log(dataConnector_conn_622s372c0e_response.value.data,'dataConnector_conn_622s372c0e_response?.value')
        console.log(projectBtn,'projectBtn?.value')
        if (!dataConnector_conn_622s372c0e_response.value.data.projectTemplate) {
  isTemplate.value = false;
  } else {
  isTemplate.value = true;
  }

       },300)
      }, {
  deep: true
  }
    )

            // 替换里程碑删除
            handle_vid_yr924znsvv_clickBtn_4mw8rxb9rg = throttle(async (...params) => {


              if(isTemplate.value===true){

            message.info('模板项目不能删除项目阶段')
              }else{
                  // 存储表格当前行数据
              const [record] = params;
              vid_yr924znsvv_props.currentRow = record;
              vid_5ukjr0mw66_props.visible = true;
              }
              }, 500)
              // 替换里程碑编辑
              handle_vid_yr924znsvv_clickBtn_j17nz2195d = throttle(async (...params) => {
                // 存储表格当前行数据
                const [record] = params;
                vid_yr924znsvv_props.currentRow = record;
                vid_m983ajvsqa_props.visible = true;
                await dataConnector_conn_z0pio5iu43()
                await dataConnector_conn_p6o2oos7qv()
                await dataConnector_conn_1dwaum0x6a()
                let mlName = document.querySelector('.vid_my2vidxokh')
                if(isTemplate.value===true){

                if(mlName) mlName.disabled = true
                }else{
                  if(mlName) mlName.disabled = false
                }
                }, 500)

                // 项目阶段新建替换
                handle_vid_07jjrs8zy0_click = throttle(async (...params) => {
                  if(isTemplate.value===true){
                    message.info('模板项目不能新建项目阶段')
                  }else{
                    await customFunction_44xnxo5zwv();
                vid_74nuuvmbbh_props.visible = true;
                  }

                }, 500)
                  // 新建模板项目合同预计开始时间校验
                       v_kcsarjbjvi_rules.q_w2frnoremk=[
          {
            required: true,
        trigger: 'blur',
        validator: (rule, value, callback) =>{
          if(!value){
            return Promise.reject('请输入合同预计开始时间')
          }
          // 与预计上线时间对比
          if ((value && v_kcsarjbjvi.w_kmxw1abh09) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') > dayjs(v_kcsarjbjvi.w_kmxw1abh09).format('YYYY-MM-DD hh-mm-ss')) {
            return Promise.reject('合同预计开始时间不能晚于合同预计上线时间')
          }else if((value && v_kcsarjbjvi.a_j1g6ir6x3p) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') > dayjs(v_kcsarjbjvi.a_j1g6ir6x3p).format('YYYY-MM-DD hh-mm-ss')){
            return Promise.reject('合同预计开始时间不能晚于合同预计完成时间')
          }
          return Promise.resolve()
        }
          }
        ]

        // 新建模板项目合同预计上线时间校验
        v_kcsarjbjvi_rules.w_kmxw1abh09=[
        {
            required: true,
        trigger: 'blur',
        validator: (rule, value, callback) =>{
          if(!value){
            return Promise.reject('请输入合同预计上线时间')
          }
          // 与预计开始时间对比
          if ((value && v_kcsarjbjvi.q_w2frnoremk) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') < dayjs(v_kcsarjbjvi.q_w2frnoremk).format('YYYY-MM-DD hh-mm-ss')) {
            return Promise.reject('合同预计上线时间不能早于合同预计开始时间')
            // 与完成时间对比
          }else if((value && v_kcsarjbjvi.a_j1g6ir6x3p) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') > dayjs(v_kcsarjbjvi.a_j1g6ir6x3p).format('YYYY-MM-DD hh-mm-ss')){
            return Promise.reject('合同预计上线时间不能晚于合同预计完成时间')
          }
          return Promise.resolve()
        }
          }
        ]
        // 新建模板项目合同预计完成时间校验
        v_kcsarjbjvi_rules.a_j1g6ir6x3p=[
        {
            required: true,
        trigger: 'blur',
        validator: (rule, value, callback) =>{
          if(!value){
            return Promise.reject('请输入合同预计完成时间')
          }
          // 与预计开始时间对比
          if ((value && v_kcsarjbjvi.q_w2frnoremk) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') < dayjs(v_kcsarjbjvi.q_w2frnoremk).format('YYYY-MM-DD hh-mm-ss')) {
            return Promise.reject('合同预计完成时间不能早于合同预计开始时间')
            // 与完成时间对比
          }else if((value && v_kcsarjbjvi.w_kmxw1abh09) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') < dayjs(v_kcsarjbjvi.w_kmxw1abh09).format('YYYY-MM-DD hh-mm-ss')){
            return Promise.reject('合同预计完成时间不能早于合同预计上线时间')
          }
          return Promise.resolve()
        }
          }
        ]


                        // 编辑模板项目合同预计开始时间校验
                        r_voe22anb6f_rules.g_s0o9cowcly=[
          {
            required: true,
        trigger: 'blur',
        validator: (rule, value, callback) =>{
          if(!value){
            return Promise.reject('请输入合同预计开始时间')
          }
          // 与预计上线时间对比
          if ((value && r_voe22anb6f.d_6owugqu7lb) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') > dayjs(r_voe22anb6f.d_6owugqu7lb).format('YYYY-MM-DD hh-mm-ss')) {
            return Promise.reject('合同预计开始时间不能晚于合同预计上线时间')
          }else if((value && r_voe22anb6f.l_9c30hu8750) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') > dayjs(r_voe22anb6f.l_9c30hu8750).format('YYYY-MM-DD hh-mm-ss')){
            return Promise.reject('合同预计开始时间不能晚于合同预计完成时间')
          }
          return Promise.resolve()
        }
          }
        ]

        // 编辑模板项目合同预计上线时间校验
        r_voe22anb6f_rules.d_6owugqu7lb=[
        {
            required: true,
        trigger: 'blur',
        validator: (rule, value, callback) =>{
          if(!value){
            return Promise.reject('请输入合同预计上线时间')
          }
          // 与预计开始时间对比
          if ((value && r_voe22anb6f.g_s0o9cowcly) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') < dayjs(r_voe22anb6f.g_s0o9cowcly).format('YYYY-MM-DD hh-mm-ss')) {
            return Promise.reject('合同预计上线时间不能早于合同预计开始时间')
            // 与完成时间对比
          }else if((value && r_voe22anb6f.l_9c30hu8750) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') > dayjs(r_voe22anb6f.l_9c30hu8750).format('YYYY-MM-DD hh-mm-ss')){
            return Promise.reject('合同预计上线时间不能晚于合同预计完成时间')
          }
          return Promise.resolve()
        }
          }
        ]

        // 新建模板项目合同预计完成时间校验
        r_voe22anb6f_rules.l_9c30hu8750=[
        {
            required: true,
        trigger: 'blur',
        validator: (rule, value, callback) =>{
          if(!value){
            return Promise.reject('请输入合同预计上线时间')
          }
          // 与预计开始时间对比
          if ((value && r_voe22anb6f.g_s0o9cowcly) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') < dayjs(r_voe22anb6f.g_s0o9cowcly).format('YYYY-MM-DD hh-mm-ss')) {
            return Promise.reject('合同预计完成时间不能早于合同预计开始时间')
            // 与完成时间对比
          }else if((value && r_voe22anb6f.d_6owugqu7lb) && dayjs(value).format('YYYY-MM-DD hh-mm-ss') < dayjs(r_voe22anb6f.d_6owugqu7lb).format('YYYY-MM-DD hh-mm-ss')){
            return Promise.reject('合同预计完成时间不能早于合同预计上线时间')
          }
          return Promise.resolve()
        }
          }
        ]



   watch(
        () => isTemplate.value,
        () => {
          console.log(isTemplate,'isTemplate')
          if(isTemplate.value===true){
            stateLi.columns=[
                {
                  title: '项目阶段',
                  dataIndex: 'milepostName',
                            resizable: true,
                  ellipsis: true,
                  width: '250px',
                  fixed: 'left',
                  align: 'left',
                  customCell: ({ rowSpan }) => {
                    return {
                      rowSpan: rowSpan
                    }
                  }
                },

                {
                  title: '任务名称',
                  dataIndex: 'taskName',
                  ellipsis: true,
                  resizable: true,
                  width: '250px',
                  fixed: 'left',
                  align: 'left',
                  customCell: ({ level, nodeType }) => {
                    return {
                      style: {
                        paddingLeft: `${(level + 1) * 20}px`,
                        color: `${nodeType === 'MENU' ? '#3875ff' : ''}`
                      }
                    }
                  }
                },
                {
                  title: '任务状态',
                  dataIndex: 'taskStatus',
                  resizable: true,
                  ellipsis: false,
                  width: '140px',
                  align: 'center'
                },
                {
                title: '验收标准',
                dataIndex: 'acceptanceCriteria',
                resizable: true,
                ellipsis: true,
                width: '200px',
                align: 'center'
              },
                        {
                title: '甲方工作事项',
                dataIndex: 'taskRemarks',
                resizable: true,
                ellipsis: true,
                width: '200px',
                align: 'center'
              },
              {
                  title: '附件',
                  dataIndex: 'attachment',
                  resizable: true,
                  ellipsis: true,
                  width: '200px',
                  align: 'center'
                },
                {
                  title: '任务负责人',
                  dataIndex: 'taskOwner',
                  resizable: true,
                  ellipsis: true,
                  width: '140px',
                  align: 'center'
                },
                {
                  title: '审核员',
                  dataIndex: 'assessorName',
                  resizable: true,
                  ellipsis: true,
                  width: '140px',
                  align: 'center'
                },

                {
                  title: '任务执行人',
                  resizable: true,
                  dataIndex: 'taskParticipantStr',
                  ellipsis: true,
                  width: '140px',
                  align: 'center'
                },
                {
                  title: '计划开始',
                  dataIndex: 'startTime',
                  resizable: true,
                  ellipsis: true,
                  width: '140px',
                  align: 'center'
                },
                {
                  title: '实际开始',
                  dataIndex: 'actualStarTime',
                  resizable: true,
                  ellipsis: true,
                  width: '140px',
                  align: 'center'
                },
                {
                  title: '计划完成',
                  dataIndex: 'endTime',
                  ellipsis: true,
                  width: '120px',
                  resizable: true,
                  align: 'center'
                },
                {
                  title: '	实际完成',
                  dataIndex: 'taskFinishTime',
                  ellipsis: true,
                  resizable: true,
                  width: '120px',
                  align: 'center'
                },
              
                {
                  title: '审批状态',
                  dataIndex: 'approvalStatus',
                  resizable: true,
                  ellipsis: true,
                  width: '200px',
                  align: 'center'
                },
                {
                  title: '优先级',
                  dataIndex: 'priorityStr',
                  resizable: true,
                  ellipsis: true,
                  width: '150px',
                  align: 'center'
                },
                {
                  title: '未关闭风险数量',
                  dataIndex: 'unclosedRiskNumber',
                  resizable: true,
                  ellipsis: true,
                  width: '160px',
                  align: 'center'
                },
                {
                  title: '风险数量',
                  dataIndex: 'riskNumber',
                  resizable: true,
                  ellipsis: true,
                  width: '160px',
                  align: 'center'
                },
                {
                  title: '任务编码',
                  dataIndex: '',
                  ellipsis: true,
                  resizable: true,
                  width: '160px',
                  align: 'center'
                },

                {
                  title: '计划工时',
                  dataIndex: 'workingHours',
                  resizable: true,
                  ellipsis: true,
                  width: '100px',
                  align: 'center'
                },
                {
                  title: '实际工时',
                  dataIndex: 'actualWorkHours',
                  resizable: true,
                  ellipsis: true,
                  width: '100px',
                  align: 'center'
                },
                {
                  title: '工时投入状态',
                  dataIndex: 'stateInput',
                  resizable: true,
                  ellipsis: true,
                  width: '200px',
                  align: 'center'
                },

                {
                  title: '任务类型',
                  dataIndex: 'taskType',
                  resizable: true,
                  ellipsis: true,
                  width: '200px',
                  align: 'center'
                },
                   
                {
                  title: '备注',
                  dataIndex: 'description',
                  resizable: true,
                  ellipsis: true,
                  width: '100px',
                  align: 'center'
                },
                
                {
                  title: '任务上下线',
                  dataIndex: 'taskStatusOnOrOff',
                  resizable: true,
                  ellipsis: true,
                  width: '120px',
                  align: 'center'
                },
                {
                  title: '依赖任务',
                  dataIndex: 'taskDependency',
                  resizable: true,
                  ellipsis: true,
                  width: '100px',
                  align: 'center'
                },
                {
                  title: '操作',
                  dataIndex: 'operation',
                  width: '430px',
                  align: 'center'
                }
              ]
          }else{
            stateLi.columns =[
            {
                  title: '项目阶段',
                  dataIndex: 'milepostName',
                            resizable: true,
                  ellipsis: true,
                  width: '250px',
                  fixed: 'left',
                  align: 'left',
                  customCell: ({ rowSpan }) => {
                    return {
                      rowSpan: rowSpan
                    }
                  }
                },
                {
                  title: '序号',
                  dataIndex: 'taskIndex',
                  resizable: true,
                  ellipsis: true,
                  width: '70px',
                  fixed: 'left',
                  align: 'left',
                  customCell: ({ level, nodeType }) => {
                    return {
                      style: {
                        paddingLeft: `${(level + 1) * 15}px`,
                        color: `${nodeType === 'MENU' ? '#3875ff' : ''}`
                      }
                    }
                  }
                },
                {
                  title: '任务名称',
                  dataIndex: 'taskName',
                  ellipsis: true,
                  resizable: true,
                  width: '250px',
                  fixed: 'left',
                  align: 'left',
                  customCell: ({ level, nodeType }) => {
                    return {
                      style: {
                        paddingLeft: `${(level + 1) * 20}px`,
                        color: `${nodeType === 'MENU' ? '#3875ff' : ''}`
                      }
                    }
                  }
                },
                {
                  title: '任务状态',
                  dataIndex: 'taskStatus',
                  resizable: true,
                  ellipsis: false,
                  width: '140px',
                  align: 'center'
                },
                {
                title: '验收标准',
                dataIndex: 'acceptanceCriteria',
                resizable: true,
                ellipsis: true,
                width: '200px',
                align: 'center'
              },
                        {
                title: '甲方工作事项',
                dataIndex: 'taskRemarks',
                resizable: true,
                ellipsis: true,
                width: '200px',
                align: 'center'
              },
              {
                  title: '附件',
                  dataIndex: 'attachment',
                  resizable: true,
                  ellipsis: true,
                  width: '200px',
                  align: 'center'
                },
                {
                  title: '任务负责人',
                  dataIndex: 'taskOwner',
                  resizable: true,
                  ellipsis: true,
                  width: '140px',
                  align: 'center'
                },
                {
                  title: '审核员',
                  dataIndex: 'assessorName',
                  resizable: true,
                  ellipsis: true,
                  width: '140px',
                  align: 'center'
                },

                {
                  title: '任务执行人',
                  resizable: true,
                  dataIndex: 'taskParticipantStr',
                  ellipsis: true,
                  width: '140px',
                  align: 'center'
                },
                {
                  title: '计划开始',
                  dataIndex: 'startTime',
                  resizable: true,
                  ellipsis: true,
                  width: '140px',
                  align: 'center'
                },
                {
                  title: '实际开始',
                  dataIndex: 'actualStarTime',
                  resizable: true,
                  ellipsis: true,
                  width: '140px',
                  align: 'center'
                },
                {
                  title: '计划完成',
                  dataIndex: 'endTime',
                  ellipsis: true,
                  width: '120px',
                  resizable: true,
                  align: 'center'
                },
                {
                  title: '	实际完成',
                  dataIndex: 'taskFinishTime',
                  ellipsis: true,
                  resizable: true,
                  width: '120px',
                  align: 'center'
                },
              
                {
                  title: '审批状态',
                  dataIndex: 'approvalStatus',
                  resizable: true,
                  ellipsis: true,
                  width: '200px',
                  align: 'center'
                },
                {
                  title: '优先级',
                  dataIndex: 'priorityStr',
                  resizable: true,
                  ellipsis: true,
                  width: '150px',
                  align: 'center'
                },
                {
                  title: '未关闭风险数量',
                  dataIndex: 'unclosedRiskNumber',
                  resizable: true,
                  ellipsis: true,
                  width: '160px',
                  align: 'center'
                },
                {
                  title: '风险数量',
                  dataIndex: 'riskNumber',
                  resizable: true,
                  ellipsis: true,
                  width: '160px',
                  align: 'center'
                },
                {
                  title: '任务编码',
                  dataIndex: '',
                  ellipsis: true,
                  resizable: true,
                  width: '160px',
                  align: 'center'
                },

                {
                  title: '计划工时',
                  dataIndex: 'workingHours',
                  resizable: true,
                  ellipsis: true,
                  width: '100px',
                  align: 'center'
                },
                {
                  title: '实际工时',
                  dataIndex: 'actualWorkHours',
                  resizable: true,
                  ellipsis: true,
                  width: '100px',
                  align: 'center'
                },
                {
                  title: '工时投入状态',
                  dataIndex: 'stateInput',
                  resizable: true,
                  ellipsis: true,
                  width: '200px',
                  align: 'center'
                },

                {
                  title: '任务类型',
                  dataIndex: 'taskType',
                  resizable: true,
                  ellipsis: true,
                  width: '200px',
                  align: 'center'
                },
                   
                {
                  title: '备注',
                  dataIndex: 'description',
                  resizable: true,
                  ellipsis: true,
                  width: '100px',
                  align: 'center'
                },
                
                {
                  title: '任务上下线',
                  dataIndex: 'taskStatusOnOrOff',
                  resizable: true,
                  ellipsis: true,
                  width: '120px',
                  align: 'center'
                },
                {
                  title: '依赖任务',
                  dataIndex: 'taskDependency',
                  resizable: true,
                  ellipsis: true,
                  width: '100px',
                  align: 'center'
                },
                {
                  title: '操作',
                  dataIndex: 'operation',
                  width: '430px',
                  align: 'center'
                }
                
             
                
              ]
          }

        }, {
    deep: true
    }
      )